writing timestamp - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: writing timestamp (/showthread.php?tid=70453) Pages:
1
2
|
writing timestamp - richb201 - 04-11-2018 This should not be the problem that it is. I am trying to update the last_login date in my table, employees. PHP Code: $query=$this->db->get_where('employees', array('employee_email'=>$email_key)); RE: writing timestamp - dave friend - 04-11-2018 One possibility is PHP Code: if($query->result_id->num_rows > 0) Or the field could be defined like so `last_login` int(11) UNSIGNED DEFAULT NULL, And then set 'last_login" this way PHP Code: $now = time(); Or change the field to `last_login` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP Which makes it automatically update. RE: writing timestamp - InsiteFX - 04-12-2018 OR load the date_helper and use it's method now() I always do it like the last one that @Dave friend mentioned RE: writing timestamp - richb201 - 04-16-2018 Works Great! I used the NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP which sure makes life easy! Thanks again. RE: writing timestamp - richb201 - 04-26-2018 I am still having a problem with this. What do I need to get the timestamp to update? i am using NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP $this->db->set('photo',$json->photo); //save this guys photo for the org chart $this->db->where('employee_email', $email_key); $this->db->update('employees'); RE: writing timestamp - InsiteFX - 04-26-2018 This is how it is done. Code: `created_at` datetime default current_timestamp, Hope that helps. RE: writing timestamp - richb201 - 04-26-2018 Thanks Insite. But what do I need to do? Do I do a where and then an update? Or should I do a replace? I made the changes but still it is not working. RE: writing timestamp - InsiteFX - 04-27-2018 It should update on any data saved to the table. update or replace. RE: writing timestamp - Paradinight - 04-27-2018 (04-26-2018, 01:39 PM)richb201 Wrote: Thanks Insite. But what do I need to do? Do I do a where and then an update? Or should I do a replace? I made the changes but still it is not working. mysql version? RE: writing timestamp - richb201 - 04-27-2018 15.1 distrib 10.1.19-MariaDB for win 32 |