Difference between #10 and #11 of
UUID instead of an auto-increment integer for ID with Active Record

Revision #11 has been created by grigori on Nov 25, 2019, 10:54:14 PM with the memo:

minor lexical update
« previous (#10) next (#12) »

Changes

Title unchanged

UUID instead of an auto-increment integer for ID with Active Record

Category unchanged

How-tos

Yii version unchanged

2.0

Tags unchanged

mysql,active record,REST,UUID

Content changed

[...]
```

Active Record does not call the getter method if attributes contain the property. It should not be this way, so I return the default component behavior and make ID returned the right way.
From the other hand, the first valiator calls `$model->id` triggering the getter before the UUID is saved to the private property so I need to serve the value from user input.

It is strange to mutate data in a validator, but I found this is the only
solutionway. I belive I shouldn't use `beforeSave()` callback to set the binary value for generating SQL, and return the text value back in `afterSave()`, - supporting this code later will be a hellwould be a classic hell like `#define true false;`.

So, now you can go the generic MySQL way

Step 4. add a virtual column
[...]
4 0
3 followers
Viewed: 21 945 times
Version: 2.0
Category: How-tos
Written by: grigori
Last updated by: samdark
Created on: Nov 25, 2019
Last updated: 7 months ago
Update Article

Revisions

View all history