cleanup docs and duplicate code in query

This commit is contained in:
Carsten Brandt
2015-11-25 13:36:12 +01:00
parent 31cf978f38
commit 7c7ed48c4c
2 changed files with 21 additions and 31 deletions

View File

@ -39,6 +39,7 @@ use yii\base\InvalidConfigException;
* ActiveQuery also provides the following additional query options:
*
* - [[with()]]: list of relations that this query should be performed with.
* - [[joinWith()]]: reuse a relation query definition to add a join to a query.
* - [[indexBy()]]: the name of the column by which the query result should be indexed.
* - [[asArray()]]: whether to return each record as an array.
*
@ -154,19 +155,8 @@ class ActiveQuery extends Query implements ActiveQueryInterface
}
if (empty($this->select) && !empty($this->join)) {
foreach ((array) $this->from as $alias => $table) {
if (is_string($alias)) {
$this->select = ["$alias.*"];
} elseif (is_string($table)) {
if (preg_match('/^(.*?)\s+({{\w+}}|\w+)$/', $table, $matches)) {
$alias = $matches[2];
} else {
$alias = $table;
}
$this->select = ["$alias.*"];
}
break;
}
list(, $alias) = $this->getQueryTableName($this);
$this->select = ["$alias.*"];
}
if ($this->primaryModel === null) {
@ -442,8 +432,8 @@ class ActiveQuery extends Query implements ActiveQueryInterface
* Inner joins with the specified relations.
* This is a shortcut method to [[joinWith()]] with the join type set as "INNER JOIN".
* Please refer to [[joinWith()]] for detailed usage of this method.
* @param string|array $with the relations to be joined with
* @param boolean|array $eagerLoading whether to eager loading the relations
* @param string|array $with the relations to be joined with.
* @param boolean|array $eagerLoading whether to eager loading the relations.
* @return $this the query object itself
* @see joinWith()
*/

View File

@ -583,13 +583,13 @@ class Query extends Component implements QueryInterface
* @param string $type the type of join, such as INNER JOIN, LEFT JOIN.
* @param string|array $table the table to be joined.
*
* Use string to represent the name of the table to be joined.
* Table name can contain schema prefix (e.g. 'public.user') and/or table alias (e.g. 'user u').
* Use a string to represent the name of the table to be joined.
* The table name can contain a schema prefix (e.g. 'public.user') and/or table alias (e.g. 'user u').
* The method will automatically quote the table name unless it contains some parenthesis
* (which means the table is given as a sub-query or DB expression).
*
* Use array to represent joining with a sub-query. The array must contain only one element.
* The value must be a Query object representing the sub-query while the corresponding key
* Use an array to represent joining with a sub-query. The array must contain only one element.
* The value must be a [[Query]] object representing the sub-query while the corresponding key
* represents the alias for the sub-query.
*
* @param string|array $on the join condition that should appear in the ON part.
@ -607,13 +607,13 @@ class Query extends Component implements QueryInterface
* Appends an INNER JOIN part to the query.
* @param string|array $table the table to be joined.
*
* Use string to represent the name of the table to be joined.
* Table name can contain schema prefix (e.g. 'public.user') and/or table alias (e.g. 'user u').
* Use a string to represent the name of the table to be joined.
* The table name can contain a schema prefix (e.g. 'public.user') and/or table alias (e.g. 'user u').
* The method will automatically quote the table name unless it contains some parenthesis
* (which means the table is given as a sub-query or DB expression).
*
* Use array to represent joining with a sub-query. The array must contain only one element.
* The value must be a Query object representing the sub-query while the corresponding key
* Use an array to represent joining with a sub-query. The array must contain only one element.
* The value must be a [[Query]] object representing the sub-query while the corresponding key
* represents the alias for the sub-query.
*
* @param string|array $on the join condition that should appear in the ON part.
@ -631,13 +631,13 @@ class Query extends Component implements QueryInterface
* Appends a LEFT OUTER JOIN part to the query.
* @param string|array $table the table to be joined.
*
* Use string to represent the name of the table to be joined.
* Table name can contain schema prefix (e.g. 'public.user') and/or table alias (e.g. 'user u').
* Use a string to represent the name of the table to be joined.
* The table name can contain a schema prefix (e.g. 'public.user') and/or table alias (e.g. 'user u').
* The method will automatically quote the table name unless it contains some parenthesis
* (which means the table is given as a sub-query or DB expression).
*
* Use array to represent joining with a sub-query. The array must contain only one element.
* The value must be a Query object representing the sub-query while the corresponding key
* Use an array to represent joining with a sub-query. The array must contain only one element.
* The value must be a [[Query]] object representing the sub-query while the corresponding key
* represents the alias for the sub-query.
*
* @param string|array $on the join condition that should appear in the ON part.
@ -655,13 +655,13 @@ class Query extends Component implements QueryInterface
* Appends a RIGHT OUTER JOIN part to the query.
* @param string|array $table the table to be joined.
*
* Use string to represent the name of the table to be joined.
* Table name can contain schema prefix (e.g. 'public.user') and/or table alias (e.g. 'user u').
* Use a string to represent the name of the table to be joined.
* The table name can contain a schema prefix (e.g. 'public.user') and/or table alias (e.g. 'user u').
* The method will automatically quote the table name unless it contains some parenthesis
* (which means the table is given as a sub-query or DB expression).
*
* Use array to represent joining with a sub-query. The array must contain only one element.
* The value must be a Query object representing the sub-query while the corresponding key
* Use an array to represent joining with a sub-query. The array must contain only one element.
* The value must be a [[Query]] object representing the sub-query while the corresponding key
* represents the alias for the sub-query.
*
* @param string|array $on the join condition that should appear in the ON part.