Оптимизация запроса на получения кол-ва записей SqlModel::count
MIRSPORTA-604 Исправление ошибок mysql
This commit is contained in:
@ -231,10 +231,10 @@ abstract class SqlModel extends Model
|
|||||||
$where = $this->db->whereExpr($where);
|
$where = $this->db->whereExpr($where);
|
||||||
$group_by = $this->db->groupByExpr($group_by);
|
$group_by = $this->db->groupByExpr($group_by);
|
||||||
$result = $this->query(
|
$result = $this->query(
|
||||||
'SELECT ' . $select_parent_query . ' FROM (' .
|
'SELECT (' .
|
||||||
(($sql_expression) ? $sql_expression : ('SELECT * FROM ' . $this->identify($this->table())))
|
(($sql_expression) ? $sql_expression : ('SELECT * FROM ' . $this->identify($this->table())))
|
||||||
. (($where) ? (' WHERE ' . $where) : '')
|
. (($where) ? (' WHERE ' . $where) : '')
|
||||||
. (($group_by) ? (' GROUP BY ' . $group_by) : '') . ') AS x',
|
. (($group_by) ? (' GROUP BY ' . $group_by) : '') . ') AS count',
|
||||||
$sql_expression_params,
|
$sql_expression_params,
|
||||||
$cache_key
|
$cache_key
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user