开发者

Doctrine: Keep 'Timestampable' behavior when using stored procedures?

开发者 https://www.devze.com 2022-12-27 22:36 出处:网络
I have complex logic which is not possible (too slow) to run through PHP with Doctrine, so I need to create a stored procedure for this. The logic also includes inserting/updating records in a table u

I have complex logic which is not possible (too slow) to run through PHP with Doctrine, so I need to create a stored procedure for this. The logic also includes inserting/updating records in a table using the Tim开发者_运维百科estampable behavior. How do I preserve this behavior in the stored procedure?


If your schema uses the default Timestampable behaviour from Doctrine, then you have the created_at and updated_at datetime columns added to your table schema. Then I'd imagine that in your stored procedure, you can update both created_at and updated_at to the current date & time (using eg NOW()) if the record is new, and only updated_at if the record is existing.

This assumes that your stored procedure can differentiate between new and existing records.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号