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.
精彩评论