Propel
Propel copied to clipboard
How can I do something like $book->setUUID("UUID()"); so MySQL can generate the UUID itself?
Hello,
I have a book model (for the sake of this example), with multiple columns, like title, author and uuid.
I'd like the uuid column to be auto-generated by MySQL any time it's empty.
So, just as I would do $book->setTitle("My first book"), I'd like to do something like $book->setUUID("UUID()"); and then MySQL will generate the UUID itself.
So, is there any way to set values from PHP with MySQL functions?
Thanks!
You shouldn't let mysql generate UUIDs due to performance reasons (indices). Better build your own index friendly UUID schema and generate those in PHP. Use <column defaultExpr=""> if you really want to use UUID() of MySQL as default (if its empty)