Welcome Guest, Not a member yet? Register   Sign In
Remove timestamp onUpdate save
#1

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
Reply
#2

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 03-09-2020, 08:44 AM by nicolas33770.)

(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
Reply
#4

If adminer doesn’t let you change that, you should use another tool instead of changing it to varchar!
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#5

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB