Fix count on not resetQuery.
This commit is contained in:
parent
8069fb28a1
commit
405cf1cb34
@ -631,11 +631,28 @@ class ModelMySQL {
|
||||
* @return int
|
||||
*/
|
||||
public static function count($resetQuery = true) {
|
||||
if (!$resetQuery)
|
||||
$backup = [
|
||||
'select' => static::$querySelect['select'],
|
||||
'sql_calc_found_rows' => static::$querySelect['sql_calc_found_rows'],
|
||||
'limit' => static::$querySelect['limit'],
|
||||
'orderBy' => static::$querySelect['orderBy']
|
||||
];
|
||||
|
||||
static::$querySelect['select'] = ['1'];
|
||||
static::$querySelect['sql_calc_found_rows'] = true;
|
||||
static::$querySelect['limit'] = '1';
|
||||
static::$querySelect['orderBy'] = '';
|
||||
|
||||
$sql = static::buildQuery($resetQuery);
|
||||
|
||||
if (!$resetQuery) {
|
||||
static::$querySelect['select'] = $backup['select'];
|
||||
static::$querySelect['sql_calc_found_rows'] = $backup['sql_calc_found_rows'];
|
||||
static::$querySelect['limit'] = $backup['limit'];
|
||||
static::$querySelect['orderBy'] = $backup['orderBy'];
|
||||
}
|
||||
|
||||
$result = static::query($sql)->fetch_assoc();
|
||||
return static::found_row();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user