php - How to write TIMESTAMPDIFF in a codeigniter sql query? -


in phpmyadmin can run query:

select timestampdiff(second,first_load,last_load) uptime table 

but how write query in codeignitor way? doesn't work:

$this->db->select('timestampdiff(second,first_load,last_load) uptime') 

the real query bit more complex, showing 1 part. full query (not working):

$this->db  ->select('n.unique_id, n.name, b.impressions, b.clicks, timestampdiff(second,first_load,last_load) uptime')  ->from(self::$_table . ' b')  ->join('sm_names n', 'n.id = b.name_id , n.blocked = \'0\' , n.unique_id != 11111111')  ->where('b.last_load >', date('y-m-d h:i:s', time() - (86400 * 2)))  ->order_by($order, 'desc')  ->limit($limit); 

it generates error message: http://screencast.com/t/zuyq58rc6ua

thanks.

try giving space after last_load in timestampdiff(second,first_load,last_load) before bracket closes.


Comments

Popular posts from this blog

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

apache - Add omitted ? to URLs -

php - How can I stop spam on my custom forum/blog? -