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

Comparing #6 with #7

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

fixing the markup

Content

[...]
Here's the hack:

Step 1 add a private $idText; property

```
 
class Video extends ActiveRecord
 
{
 
    private $idText;
 
 
```
 
 
Step 2 add two filters

```
[...]
// this is a workaround for lack of mapping in active record
['id','filter','skipOnError'=>true, 'filter'=>function($uuid){
  $this->idText = $uuid;    return pack("H*", str_replace('-', '', $uuid));    }],
```
These filters will validate input, prepare UUID to be written in a binary format and keep the text form for output.
[...]
So, now you can go the generic mysql way

 
Step 4. add a virtual column

```
ALTER TABLE t1 ADD id_text varchar(36) generated always as
(insert(
insert(
[...]