Active Record Update: using NOW() and other SQL |
[eluser]suntrop[/eluser]
I want to insert the current time and increment one field. Code: $data = array( … but I get an error, because CI produces this code: Code: UPDATE `p_users` SET `last_login` = 'NOW()', `login_count` = 'login_count + 1' WHERE `id` = '1' I read that I can prevent escaping for INSERT. But what about UPDATE? What I am doing wrong?
[eluser]pmoroom[/eluser]
[quote author="suntrop" date="1309646823"]I want to insert the current time and increment one field. Code: $data = array( … but I get an error, because CI produces this code: Code: UPDATE `p_users` SET `last_login` = 'NOW()', `login_count` = 'login_count + 1' WHERE `id` = '1' I read that I can prevent escaping for INSERT. But what about UPDATE? What I am doing wrong?[/quote] Go here: http://ellislab.com/codeigniter/user-gui...ecord.html Search for "$this->db->set();" and have a quick read. Something like this should work: Code: $this->db->set('last_login', 'NOW()', FALSE);
[eluser]InsiteFX[/eluser]
Code: $now = date("H:i:s"); InsiteFX
[eluser]suntrop[/eluser]
Thanks! I thought there is a way I can use the array as well. |
Welcome Guest, Not a member yet? Register Sign In |