CodeIgniter Forums
Remove timestamp onUpdate save - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Remove timestamp onUpdate save (/showthread.php?tid=75713)



Remove timestamp onUpdate save - nicolas33770 - 03-09-2020

Hello everyone,

I use CI3 and Adminer on my project. I have a field "contact_create_time", and I would like to save the create timestamp here. In the options on adminer I can't leave blank, I don't know if it's the problem ?

[Image: Capture-d-e-cran-2020-03-09-a-11-34-33.png]

Code:
        $this->contact_create_time  = date("Y-m-d H:i:s");

        $this->db->insert('contact', $this);

The save is OK. But on update I don't add any update "contact_create_time" and the timestamp are updated...  Undecided


RE: Remove timestamp onUpdate save - InsiteFX - 03-09-2020

When you save or update the record the database is updating your time field.

That's what the (ON UPDATE) CURRENT_TIMESTAMP means.


If you do not want it to update the field remove that.


RE: Remove timestamp onUpdate save - nicolas33770 - 03-09-2020

(03-09-2020, 08:42 AM)InsiteFX Wrote: When you save or update the record the database is updating your time field.

That's what the (ON UPDATE) CURRENT_TIMESTAMP means.


If you do not want it to update the field remove that.

Thanks for your help. Yes I know but I can't do that on Adminer interface. It's strange. I save me timestamp on varchar to solve my problem...  Undecided


RE: Remove timestamp onUpdate save - includebeer - 03-09-2020

If adminer doesn’t let you change that, you should use another tool instead of changing it to varchar!


RE: Remove timestamp onUpdate save - nicolas33770 - 03-09-2020

I can change to VARCHAR and I think I can do with SQL too, but I would like to know if the problem come from adminer and not CI... Thanks