Doctrine\DBAL\Connection::exec PHP Method

exec() public method

Executes an SQL statement and return the number of affected rows.
public exec ( string $statement ) : integer
$statement string
return integer The number of affected rows.
    public function exec($statement)
    {
        $this->connect();
        $logger = $this->_config->getSQLLogger();
        if ($logger) {
            $logger->startQuery($statement);
        }
        try {
            $result = $this->_conn->exec($statement);
        } catch (Exception $ex) {
            throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $statement);
        }
        if ($logger) {
            $logger->stopQuery();
        }
        return $result;
    }

Usage Example

コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function purge()
 {
     foreach ($this->tables as $table) {
         $sql = 'DELETE FROM ' . $table;
         $this->connection->exec($sql);
     }
 }
All Usage Examples Of Doctrine\DBAL\Connection::exec