Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] RE: How to prevent auto-update of $createdField and $updatedField
#1
Wink 
(This post was last modified: 06-06-2021, 09:20 AM by BlackBones.)

Hello guys.
I am using CI4 (auto) Model.
I want to prevent auto-update of created_at and updated_at in my database table so I can set the values manually. The problem is for example, the 'created_at' and 'updated_at' fields are both updated with the current timestamp, and in so doing, the original date and time a user registers an account is changed, and my application loses track of the original timestamp.
I have followed the documentation about $useTimestamps, $createdField, $updatedField exactly...even leaving both $createdField and $updatedField empty (as instructed in the documentation) and I'm still not able to prevent the auto-update.
Any help anyone please?
Thanks ahead!
Heart Heart Heart
Reply
#2

Try setting the `$useTimestamps` property to `false`.
Reply
#3

(This post was last modified: 06-06-2021, 09:17 AM by BlackBones.)

Thank you @paulbalandan. Have you had any need to want to achieve same?
I did that, but no way. That's the reason I showed up here if anyone has had any experience with it, and if there's a resolution.
Let's hope I'm right though.



It is SOLVED!!!
Took a deeper look at my CI Model class...my $beforeInsert and $beforeUpdate callbacks (or I Rolleyes) were guilty.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB