CodeIgniter Forums
How to use SQL_CALC_FOUND_ROWS function on active record with select method - 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: How to use SQL_CALC_FOUND_ROWS function on active record with select method (/showthread.php?tid=64966)



How to use SQL_CALC_FOUND_ROWS function on active record with select method - chan15 - 04-14-2016

I know we can use SQL_CALC_FOUND_ROWS  and FOUND_ROWS() like

PHP Code:
$this->db->select('SQL_CALC_FOUND_ROWS *'false);

// And get the result
$query $this->db->query('SELECT FOUND_ROWS() AS `count`');
$totalRows $query->row()->count

But if we want to select the column by our own like

PHP Code:
$this->db->select('SQL_CALC_FOUND_ROWS *'false);
$this->db->select('a.name, b.age'); 

This will work but come out the sql string like "SELECT SQL_CALC_FOUND_ROWS *, `a`.`name`, `b`.`age`", actually get everything from table a and table b, how to make it like "SELECT SQL_CALC_FOUND_ROWS `a`.`name`, `b`.`age`"