![]() |
"updated_at" field filled during an insert operation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: "updated_at" field filled during an insert operation (/showthread.php?tid=91265) Pages:
1
2
|
"updated_at" field filled during an insert operation - Renta Ardhana - 07-11-2024 the updated_at field filled during an insert operation, not only created_at field. Even though I only intend to insert into the database. is it normal? thanks. RE: "updated_at" field filled during an insert operation - InsiteFX - 07-11-2024 Yes anytime you update a database record the updated_at field will ne updated. RE: "updated_at" field filled during an insert operation - Renta Ardhana - 07-12-2024 Thank you for your quick response... So, it's normal for both the 'created_at' and 'updated_at' fields to be filled when we INSERT data into the database (not update operation). PS: i'm using SQLite3 RE: "updated_at" field filled during an insert operation - InsiteFX - 07-12-2024 Created_at is only created when the record is created. updated_at is updated every time the record is changed with new data. RE: "updated_at" field filled during an insert operation - Renta Ardhana - 07-13-2024 (07-12-2024, 10:06 PM)InsiteFX Wrote: updated_at is updated every time the record is changed with new data. Thanks @InsiteFX , but I don't understand the second sentence. Will 'created_at' be updated even though it is the first time the record is inserted? RE: "updated_at" field filled during an insert operation - wdeda - 07-13-2024 The structure to be used is as follows: type => DATETIME default => null attributes => on update CURRENT_TIMESTAMP RE: "updated_at" field filled during an insert operation - Renta Ardhana - 07-13-2024 (07-13-2024, 07:26 PM)wdeda Wrote: The structure to be used is as follows: my SQLite IDE does not support the DATETIME data type; it only allows text or integer types. RE: "updated_at" field filled during an insert operation - InsiteFX - 07-13-2024 created_at is only set once when the record is created, it will never be set again unless you change it. updated_at is changed every time you insert or update the record. RE: "updated_at" field filled during an insert operation - wdeda - 07-14-2024 My apologies, I didn't actually read your remark that you use SQLite3. I agree with @InsiteFX, but what you reported is possible to happen in MySql if 'updated_at' is not set properly. RE: "updated_at" field filled during an insert operation - Renta Ardhana - 07-14-2024 (07-13-2024, 10:08 PM)InsiteFX Wrote: created_at is only set once when the record is created, it will never be set again unless you change it. Thank you, the answer that really helps me understand why the updated_at field contains data even though I only inserted new data once. (07-14-2024, 04:11 AM)wdeda Wrote: My apologies, I didn't actually read your remark that you use SQLite3. I agree with @InsiteFX, but what you reported is possible to happen in MySql if 'updated_at' is not set properly. I also forgot I was using an SQLite db ![]() |