Commit 6cffc2b7 authored by Adrien Clairembault's avatar Adrien Clairembault Committed by Johan Cwiklinski
Browse files

Replace SQL_CALC_FOUNDS_ROWS by count

parent 92540a94
......@@ -1279,7 +1279,7 @@ abstract class API extends CommonGLPI {
$add_keys_names = count($params['add_keys_names']) > 0;
// build query
$query = "SELECT SQL_CALC_FOUND_ROWS DISTINCT ".$DB->quoteName("$table.id").", ".$DB->quoteName("$table.*")."
$query = "SELECT DISTINCT ".$DB->quoteName("$table.id").", ".$DB->quoteName("$table.*")."
FROM ".$DB->quoteName($table)."
$join
WHERE $where
......@@ -1301,8 +1301,8 @@ abstract class API extends CommonGLPI {
}
// get result full row counts
$data_numtotalrow = $DB->request('SELECT FOUND_ROWS()')->next();
$totalcount = $data_numtotalrow['FOUND_ROWS()'];
$count_query = "SELECT COUNT(*) FROM {$DB->quoteName($table)} $join WHERE $where";
$totalcount = $DB->query($count_query)->fetch_row()[0];
if ($params['range'][0] > $totalcount) {
$this->returnError("Provided range exceed total count of data: ".$totalcount,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment