本文整理汇总了PHP中yii\db\ActiveQuery::prepare方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveQuery::prepare方法的具体用法?PHP ActiveQuery::prepare怎么用?PHP ActiveQuery::prepare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\db\ActiveQuery
的用法示例。
在下文中一共展示了ActiveQuery::prepare方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
public function prepare($builder)
{
if ($this->type !== null) {
$this->andWhere(['type' => $this->type]);
}
return parent::prepare($builder);
}
示例2: prepare
public function prepare($builder)
{
if ($this->type !== null) {
$this->andWhere(['competition_type' => $this->type]);
Yii::trace($this->type, 'CompetitionQuery::prepare');
}
return parent::prepare($builder);
}
示例3: prepare
public function prepare($builder)
{
// override private `buildJoinWith()`
if (!empty($this->joinWith)) {
$this->buildJoinWith();
$this->joinWith = null;
// clean it up to avoid issue https://github.com/yiisoft/yii2/issues/2687
}
if (empty($this->from)) {
$this->from = [$this->finder->tableName()];
}
return parent::prepare($builder);
}
示例4: prepare
/**
* @param \yii\db\QueryBuilder $builder
* @return \yii\db\Query
* @throws \yii\base\InvalidConfigException
*/
public function prepare($builder)
{
/** @var ActiveRecord $modelClass */
$modelClass = $this->modelClass;
$schema = $modelClass::getTableSchema();
if (empty($this->select)) {
$this->select('*');
foreach ($schema->columns as $column) {
if (ActiveRecord::isSpatial($column)) {
$field = $column->name;
$this->addSelect(["AsText({$field}) AS {$field}"]);
}
}
} else {
foreach ($this->select as $column => $field) {
$column = $schema->getColumn(is_numeric($column) ? $field : $column);
if (ActiveRecord::isSpatial($column)) {
$this->addSelect(["AsText({$field}) AS {$field}"]);
}
}
}
return parent::prepare($builder);
}
示例5: prepare
public function prepare($builder)
{
if (!$this->_skipPrep) {
// skip in case of queryScalar; it's not needed, and we get an SQL error (duplicate column names)
if (empty($this->select)) {
$this->select('*');
$this->allColumns();
} else {
/** @var ActiveRecord $modelClass */
$modelClass = $this->modelClass;
$schema = $modelClass::getTableSchema();
foreach ($this->select as $field) {
if ($field == '*') {
$this->allColumns();
} else {
$column = $schema->getColumn($field);
if (ActiveRecord::isSpatial($column)) {
$this->addSelect(["AsText({$field}) AS {$field}"]);
}
}
}
}
}
return parent::prepare($builder);
}
示例6: assertSqlQuery
/**
* @param ActiveQuery $query1
* @param ActiveQuery $query2
* @param string $message
*/
public function assertSqlQuery($query1, $query2, $message = '')
{
$this->assertEquals($query1->prepare(Yii::$app->db->queryBuilder)->createCommand()->rawSql, $query2->prepare(Yii::$app->db->queryBuilder)->createCommand()->rawSql, $message);
}
示例7: prepare
public function prepare($builder)
{
$this->andWhere(['is_layout' => (bool) $this->isLayout]);
return parent::prepare($builder);
}
示例8: prepare
/**
* Maria-specific preparation for building a query that includes a dynamic column.
*
* @param \yii\db\QueryBuilder $builder
*
* @return \yii\db\Query
* @throws \yii\base\Exception
* @throws \yii\base\InvalidConfigException
*/
public function prepare($builder)
{
/** @var DynamicActiveRecord $modelClass */
$modelClass = $this->modelClass;
$this->_dynamicColumn = $modelClass::dynamicColumn();
if (empty($this->_dynamicColumn)) {
/** @var string $modelClass */
throw new \yii\base\InvalidConfigException($modelClass . '::dynamicColumn() must return an attribute name');
}
if (empty($this->select)) {
$this->select[] = '*';
}
if (is_array($this->select) && in_array('*', $this->select)) {
$db = $modelClass::getDb();
$this->select[$this->_dynamicColumn] = 'COLUMN_JSON(' . $db->quoteColumnName($this->_dynamicColumn) . ')';
}
return parent::prepare($builder);
}