I'm doing a simple MySQL query to count the number of rows a query is returning without the effect of the LIMIT
clause. I'm using Active Records with Codeigniter PHP framework.
Problem: I'm getting an error when SQL_CALC_FOUND_ROWS
is used. Why is this so?
Query
SELECT `listing_id`, SQL_CALC_FOUND_ROWS listing_id FROM (`listings`) LIMIT 100
Error
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 'SQL_CALC_FOUND_ROWS listing_id FROM (
listings
) LIMIT 100' at line 1
Codeigniter Active Records
$this->db->select('listing_id')
->select('SQL_CALC_FOUND_ROWS listing_id', FALSE)
->from('listings')
->where('price < 1000')
->limit($limit, $offset)
->order_by('listing_id', 'desc');