![]() |
Active Record SELECT bug? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Active Record SELECT bug? (/showthread.php?tid=11974) |
Active Record SELECT bug? - El Forum - 09-30-2008 [eluser]Armorfist[/eluser] EDIT: Second parameter of Active Record SELECT function to FALSE solved it. Sorry for the wrong bug report! Hello, I have the following query: Code: $this->db->select('sess.session_id,sess.ip,sess.location,sess.login_date,users.username,users.id as user_id,TIMESTAMPDIFF('.$format.',NOW(),FROM_UNIXTIME(sess.timestamp)) as time_diff')->from($table_name); When I run it, it retrieves this error: Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near: '`MINUTE`, NOW(), FROM_UNIXTIME(sess.timestamp)) as time_diff FROM (`login_sessio' at line 1 This is caused because for some reason active record adds `` to the MINUTE bit. Here's the query ActiveRecord produces: Code: SELECT sess.session_id, sess.ip, sess.location, sess.login_date Here's how it should be: Code: SELECT sess.session_id, sess.ip, sess.location, sess.login_date Notice `MINUTE` instead of MINUTE Any response will be appreciated. Thanks, Frederico EDIT: Second parameter of Active Record SELECT function to FALSE solved it. Sorry for the wrong bug report! |