From 794df81628617c27679d0d62cd1070d0ffd01038 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Mon, 12 Nov 2012 03:47:24 -0800 Subject: [PATCH] renamed order and group to orderBy and groupBy --- framework/db/ar/ActiveFinder.php | 20 +++++++++--------- framework/db/ar/ActiveRecord.php | 2 +- framework/db/dao/BaseQuery.php | 44 +++++++++++++++++++-------------------- framework/db/dao/QueryBuilder.php | 4 ++-- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/framework/db/ar/ActiveFinder.php b/framework/db/ar/ActiveFinder.php index e1be9bb..3334d79 100644 --- a/framework/db/ar/ActiveFinder.php +++ b/framework/db/ar/ActiveFinder.php @@ -467,21 +467,21 @@ class ActiveFinder extends \yii\base\Object } } - if ($element->query->order !== null) { - if (!is_array($element->query->order)) { - $element->query->order = preg_split('/\s*,\s*/', trim($element->query->order), -1, PREG_SPLIT_NO_EMPTY); + if ($element->query->orderBy !== null) { + if (!is_array($element->query->orderBy)) { + $element->query->orderBy = preg_split('/\s*,\s*/', trim($element->query->orderBy), -1, PREG_SPLIT_NO_EMPTY); } - foreach ($element->query->order as $order) { - $query->order[] = strtr($order, $prefixes); + foreach ($element->query->orderBy as $order) { + $query->orderBy[] = strtr($order, $prefixes); } } - if ($element->query->group !== null) { - if (!is_array($element->query->group)) { - $element->query->group = preg_split('/\s*,\s*/', trim($element->query->group), -1, PREG_SPLIT_NO_EMPTY); + if ($element->query->groupBy !== null) { + if (!is_array($element->query->groupBy)) { + $element->query->groupBy = preg_split('/\s*,\s*/', trim($element->query->groupBy), -1, PREG_SPLIT_NO_EMPTY); } - foreach ($element->query->group as $group) { - $query->group[] = strtr($group, $prefixes); + foreach ($element->query->groupBy as $group) { + $query->groupBy[] = strtr($group, $prefixes); } } diff --git a/framework/db/ar/ActiveRecord.php b/framework/db/ar/ActiveRecord.php index b3b69e4..f8370d0 100644 --- a/framework/db/ar/ActiveRecord.php +++ b/framework/db/ar/ActiveRecord.php @@ -71,7 +71,7 @@ abstract class ActiveRecord extends Model if (isset(self::$_models[$className])) { return self::$_models[$className]; } else { - return self::$_models[$className] = new static; + return self::$_models[$className] = new static; } } diff --git a/framework/db/dao/BaseQuery.php b/framework/db/dao/BaseQuery.php index fdbfc58..a9a8896 100644 --- a/framework/db/dao/BaseQuery.php +++ b/framework/db/dao/BaseQuery.php @@ -59,12 +59,12 @@ class BaseQuery extends \yii\base\Component * @var string|array how to sort the query results. This refers to the ORDER BY clause in a SQL statement. * It can be either a string (e.g. `'id ASC, name DESC'`) or an array (e.g. `array('id ASC', 'name DESC')`). */ - public $order; + public $orderBy; /** * @var string|array how to group the query results. This refers to the GROUP BY clause in a SQL statement. * It can be either a string (e.g. `'company, department'`) or an array (e.g. `array('company', 'department')`). */ - public $group; + public $groupBy; /** * @var string|array how to join with other tables. This refers to the JOIN clause in a SQL statement. * It can be either a string (e.g. `'LEFT JOIN tbl_user ON tbl_user.id=author_id'`) or an array (e.g. @@ -330,9 +330,9 @@ class BaseQuery extends \yii\base\Component * @return BaseQuery the query object itself * @see addGroup() */ - public function group($columns) + public function groupBy($columns) { - $this->group = $columns; + $this->groupBy = $columns; return $this; } @@ -347,16 +347,16 @@ class BaseQuery extends \yii\base\Component */ public function addGroup($columns) { - if (empty($this->group)) { - $this->group = $columns; + if (empty($this->groupBy)) { + $this->groupBy = $columns; } else { - if (!is_array($this->group)) { - $this->group = preg_split('/\s*,\s*/', trim($this->group), -1, PREG_SPLIT_NO_EMPTY); + if (!is_array($this->groupBy)) { + $this->groupBy = preg_split('/\s*,\s*/', trim($this->groupBy), -1, PREG_SPLIT_NO_EMPTY); } if (!is_array($columns)) { $columns = preg_split('/\s*,\s*/', trim($columns), -1, PREG_SPLIT_NO_EMPTY); } - $this->group = array_merge($this->group, $columns); + $this->groupBy = array_merge($this->groupBy, $columns); } return $this; } @@ -428,9 +428,9 @@ class BaseQuery extends \yii\base\Component * @return BaseQuery the query object itself * @see addOrder() */ - public function order($columns) + public function orderBy($columns) { - $this->order = $columns; + $this->orderBy = $columns; return $this; } @@ -443,18 +443,18 @@ class BaseQuery extends \yii\base\Component * @return BaseQuery the query object itself * @see order() */ - public function addOrder($columns) + public function addOrderBy($columns) { - if (empty($this->order)) { - $this->order = $columns; + if (empty($this->orderBy)) { + $this->orderBy = $columns; } else { - if (!is_array($this->order)) { - $this->order = preg_split('/\s*,\s*/', trim($this->order), -1, PREG_SPLIT_NO_EMPTY); + if (!is_array($this->orderBy)) { + $this->orderBy = preg_split('/\s*,\s*/', trim($this->orderBy), -1, PREG_SPLIT_NO_EMPTY); } if (!is_array($columns)) { $columns = preg_split('/\s*,\s*/', trim($columns), -1, PREG_SPLIT_NO_EMPTY); } - $this->order = array_merge($this->order, $columns); + $this->orderBy = array_merge($this->orderBy, $columns); } return $this; } @@ -540,7 +540,7 @@ class BaseQuery extends \yii\base\Component * takes precedence over this query. * - [[where]], [[having]]: the new query's corresponding property value * will be 'AND' together with the existing one. - * - [[params]], [[order]], [[group]], [[join]], [[union]]: the new query's + * - [[params]], [[orderBy]], [[groupBy]], [[join]], [[union]]: the new query's * corresponding property value will be appended to the existing one. * * In general, the merging makes the resulting query more restrictive and specific. @@ -591,12 +591,12 @@ class BaseQuery extends \yii\base\Component $this->addParams($query->params); } - if ($query->order !== null) { - $this->addOrder($query->order); + if ($query->orderBy !== null) { + $this->addOrderBy($query->orderBy); } - if ($query->group !== null) { - $this->addGroup($query->group); + if ($query->groupBy !== null) { + $this->addGroup($query->groupBy); } if ($query->join !== null) { diff --git a/framework/db/dao/QueryBuilder.php b/framework/db/dao/QueryBuilder.php index 407179e..bc5845a 100644 --- a/framework/db/dao/QueryBuilder.php +++ b/framework/db/dao/QueryBuilder.php @@ -69,10 +69,10 @@ class QueryBuilder extends \yii\base\Object $this->buildFrom($query->from), $this->buildJoin($query->join), $this->buildWhere($query->where), - $this->buildGroup($query->group), + $this->buildGroup($query->groupBy), $this->buildHaving($query->having), $this->buildUnion($query->union), - $this->buildOrder($query->order), + $this->buildOrder($query->orderBy), $this->buildLimit($query->limit, $query->offset), ); return implode($this->separator, array_filter($clauses));