createCommand() public method

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.
return Command the created DB command instance.
 public function createCommand($db = null)
 {
     if ($db === null) {
         $db = Yii::$app->getDb();
     }
     return parent::createCommand($db);
 }
Example #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);
 }