![]() |
Insert batch didn't update the created_at field? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: Insert batch didn't update the created_at field? (/showthread.php?tid=77667) |
Insert batch didn't update the created_at field? - mrardiyansyah - 10-01-2020 I am wondering why when I insert data using "insertBatch" the create_at field is still NULL? is there anyone here can explain it? RE: Insert batch didn't update the created_at field? - nc03061981 - 10-04-2020 You have some code Set this: $this->$useTimestamps = true; $this = $yourModel RE: Insert batch didn't update the created_at field? - mrardiyansyah - 10-31-2020 (10-04-2020, 02:11 AM)nc03061981 Wrote: You have some code Yes, I have set useTimestamps = true in the model, but oddly it doesn't update in the database. Why? RE: Insert batch didn't update the created_at field? - paulbalandan - 10-31-2020 Did you include the created at field in the allowed fields? RE: Insert batch didn't update the created_at field? - mrardiyansyah - 10-31-2020 (10-31-2020, 06:19 AM)paulbalandan Wrote: Did you include the created at field in the allowed fields?Of course, I did. Same as in the documentaion. PHP Code: protected $useTimestamps = true; RE: Insert batch didn't update the created_at field? - paulbalandan - 11-01-2020 Can you post your model code? RE: Insert batch didn't update the created_at field? - wdeda - 11-01-2020 I had the same problem, which is intermittent, because it occurs in certain processes and not in others, without any indication of why. I also noticed that when there are no problems it updates both the created_at and updated_at fields, with exactly the same date and time. The solution I found was to define created_at, update_at and deleted_at, with a null value; created_at plus null with default "current timestamp" and "updated_at" plus null with attribute "n update current timestamp" The update is done via form, as below. Model: PHP Code: <?php namespace App\Models; Controller: PHP Code: public function artmov() View: PHP Code: <!-- 20200514 --> |