• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use SQL_CALC_FOUND_ROWS function on active record with select method

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`"

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.