yii\db\Command::execute PHP 메소드

execute() 공개 메소드

This method should only be used for executing non-query SQL statement, such as INSERT, DELETE, UPDATE SQLs. No result set will be returned.
public execute ( ) : integer
리턴 integer number of rows affected by the execution.
    public function execute()
    {
        $sql = $this->getSql();
        $rawSql = $this->getRawSql();
        Yii::info($rawSql, __METHOD__);
        if ($sql == '') {
            return 0;
        }
        $this->prepare(false);
        $token = $rawSql;
        try {
            Yii::beginProfile($token, __METHOD__);
            $this->pdoStatement->execute();
            $n = $this->pdoStatement->rowCount();
            Yii::endProfile($token, __METHOD__);
            $this->refreshTableSchema();
            return $n;
        } catch (\Exception $e) {
            Yii::endProfile($token, __METHOD__);
            throw $this->db->getSchema()->convertException($e, $rawSql);
        }
    }

Usage Example

예제 #1
0
 /**
  * Extended functional: flushing request local cache.
  * @inheritdoc
  */
 public function execute()
 {
     static::$requestLocalCache->flush();
     return parent::execute();
 }