Propel icon indicating copy to clipboard operation
Propel copied to clipboard

How can I do something like $book->setUUID("UUID()"); so MySQL can generate the UUID itself?

Open MihaiValentin opened this issue 10 years ago • 1 comments

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!

MihaiValentin avatar Sep 28 '15 14:09 MihaiValentin

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)

marcj avatar Sep 28 '15 14:09 marcj