If you are going to insert a row into the database using an object, you are going to need to pass in values that do not leverage SQL functions. insertObject()
will treat the object's payload as literal values for security/stability.
Another bit of magic is that you must not try to declare a null
value in your object's payload. Instead, you should omit the property from the object entirely if you wish NULL
to be added for a given database table column.
I don't see anywhere in the insertObject()
method's argument signature to allow SQL keywords/functions to be rendered. Unless someone else knows better than me, this means you should use PHP's datetime capabilities to populate the current time.
That said, I think my best advice is to set the column's default value to the current datetime. This way you never need to mention the column when you build an insert object.
A "TRIGGER" can be helpful if you want update update_timestamp
after every change made.
Maybe these will inspire: