本文整理汇总了PHP中yii\db\Query::prepareBuild方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::prepareBuild方法的具体用法?PHP Query::prepareBuild怎么用?PHP Query::prepareBuild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\db\Query
的用法示例。
在下文中一共展示了Query::prepareBuild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
/**
* Generates a SELECT SQL statement from a [[Query]] object.
* @param Query $query the [[Query]] object from which the SQL statement will be generated.
* @param array $params the parameters to be bound to the generated SQL statement. These parameters will
* be included in the result with the additional parameters generated during the query building process.
* @return array the generated SQL statement (the first array element) and the corresponding
* parameters to be bound to the SQL statement (the second array element). The parameters returned
* include those provided in `$params`.
*/
public function build($query, $params = [])
{
$query->prepareBuild($this);
$params = empty($params) ? $query->params : array_merge($params, $query->params);
$clauses = [$this->buildSelect($query->select, $params, $query->distinct, $query->selectOption), $this->buildFrom($query->from, $params), $this->buildJoin($query->join, $params), $this->buildWhere($query->where, $params), $this->buildGroupBy($query->groupBy), $this->buildHaving($query->having, $params), $this->buildOrderBy($query->orderBy), $this->buildLimit($query->limit, $query->offset)];
$sql = implode($this->separator, array_filter($clauses));
$union = $this->buildUnion($query->union, $params);
if ($union !== '') {
$sql = "({$sql}){$this->separator}{$union}";
}
return [$sql, $params];
}