createCommand() public méthode

Creates a DB command that can be used to execute this query.
public createCommand ( Connection | null $db = null ) : Command
$db Connection | null the DB connection used to create the DB command. If `null`, the DB connection returned by [[modelClass]] will be used.
Résultat Command the created DB command instance.
 public function createCommand($db = null)
 {
     if ($db === null) {
         $db = Yii::$app->getDb();
     }
     return parent::createCommand($db);
 }
Exemple #2
0
 public function createCommand($db = null)
 {
     if ($this->commonOnly) {
         $modelClass = $this->modelClass;
         $table = $modelClass::tableName();
         $this->andWhere([$table . '.obschij' => true]);
     }
     return parent::createCommand($db);
 }