当前位置: 首页>>代码示例>>PHP>>正文


PHP ActiveQuery::prepare方法代码示例

本文整理汇总了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);
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:7,代码来源:PageQuery.php

示例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);
 }
开发者ID:kleitz,项目名称:golfleague,代码行数:8,代码来源:CompetitionQuery.php

示例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);
 }
开发者ID:slavcodev,项目名称:yii2-yii-bridge,代码行数:13,代码来源:ActiveQuery.php

示例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);
 }
开发者ID:nfilin,项目名称:yii2-libs,代码行数:28,代码来源:ActiveQuery.php

示例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);
 }
开发者ID:sjaakp,项目名称:yii2-spatial,代码行数:25,代码来源:ActiveQuery.php

示例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);
 }
开发者ID:phpshko,项目名称:yii2-magic-scopes,代码行数:9,代码来源:MagicScopesTest.php

示例7: prepare

 public function prepare($builder)
 {
     $this->andWhere(['is_layout' => (bool) $this->isLayout]);
     return parent::prepare($builder);
 }
开发者ID:DevGroup-ru,项目名称:dotplant-monster,代码行数:5,代码来源:TemplateQuery.php

示例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);
 }
开发者ID:nineinchnick,项目名称:yii2-dynamic-ar,代码行数:27,代码来源:DynamicActiveQuery.php


注:本文中的yii\db\ActiveQuery::prepare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。