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

Comparing #2 with #3

Revision #3 was created by grigori grigori on Nov 25, 2019, 10:13:23 PM.

fixing the markup

Content

[...]
Adding getId()/setId() won't help - data comes from a client in JSON and fills the model object with a setAttributes() call avoiding generic magic methods.

Here's the hack:
1. add a private $idText; property
2. add two filters

 
```
['id','match', 'pattern'=>'/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i'],
// convert UUID from text value to binary and store the text value in a private variable
// this is a workaround for lack of mapping in active record
['id','filter','skipOnError'=>true, 'filter'=>function($uuid){
$this->idText = $uuid;
[...]