I am using a simple select statement using SQL_CALC_FOUND_ROWS in zf2. The code would look like as follows and uses quantifier.
$select = $this->getSlaveSql()->select('posts');
$select->quantifier(new Expression('SQL_CALC_FOUND_ROWS'));
$select->columns([
'total'=>new Expression("FOUND_ROWS()"),
'*'
]);
And the generated sql is as below
SELECT SQL_CALC_FOUND_ROWS FOUND_ROWS() AS `total`, `posts`.* FROM `posts`
screenshot:
But for some reasons, found_rows is always returned as 0 and I do not want to add a second query for pagination. Please help.