writing timestamp |
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));
proof that an old dog can learn new tricks
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.
OR load the date_helper and use it's method now()
I always do it like the last one that @Dave friend mentioned What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Works Great! I used the NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP which sure makes life easy! Thanks again.
proof that an old dog can learn new tricks
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');
proof that an old dog can learn new tricks
This is how it is done.
Code: `created_at` datetime default current_timestamp, Hope that helps. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
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.
proof that an old dog can learn new tricks
It should update on any data saved to the table.
update or replace. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
15.1 distrib 10.1.19-MariaDB for win 32
proof that an old dog can learn new tricks
|
Welcome Guest, Not a member yet? Register Sign In |