Doctrine\DBAL\Statement::execute PHP Метод

execute() публичный Метод

Executes the statement with the currently bound parameters.
public execute ( array | null $params = null ) : boolean
$params array | null
Результат boolean TRUE on success, FALSE on failure.
    public function execute($params = null)
    {
        if (is_array($params)) {
            $this->params = $params;
        }
        $logger = $this->conn->getConfiguration()->getSQLLogger();
        if ($logger) {
            $logger->startQuery($this->sql, $this->params, $this->types);
        }
        try {
            $stmt = $this->stmt->execute($params);
        } catch (\Exception $ex) {
            if ($logger) {
                $logger->stopQuery();
            }
            throw DBALException::driverExceptionDuringQuery($this->conn->getDriver(), $ex, $this->sql, $this->conn->resolveParams($this->params, $this->types));
        }
        if ($logger) {
            $logger->stopQuery();
        }
        $this->params = array();
        $this->types = array();
        return $stmt;
    }

Usage Example

Пример #1
0
 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     $this->createStatement();
     /** @var \DateTime $date */
     $date = $record['datetime'];
     /** @var ContaoContext $context */
     $context = $record['extra']['contao'];
     $this->statement->execute(['tstamp' => $date->format('U'), 'text' => StringUtil::specialchars((string) $record['formatted']), 'source' => (string) $context->getSource(), 'action' => (string) $context->getAction(), 'username' => (string) $context->getUsername(), 'func' => (string) $context->getFunc(), 'ip' => (string) $context->getIp(), 'browser' => (string) $context->getBrowser()]);
 }
All Usage Examples Of Doctrine\DBAL\Statement::execute