driverExceptionDuringQuery() 공개 정적인 메소드

public static driverExceptionDuringQuery ( Doctrine\DBAL\Driver $driver, Exception $driverEx, string $sql, array $params = [] ) : DBALException
$driver Doctrine\DBAL\Driver
$driverEx Exception
$sql string
$params array
리턴 DBALException
예제 #1
1
 /**
  * @return array
  */
 public function validateDataProvider()
 {
     return [[$this->getDataSourceInterfaceMock(), false, DBALException::driverExceptionDuringQuery(new \Exception('failed'), 'sql')], [$this->getDataSourceInterfaceMock(), false, new InvalidConfigurationException()], [$this->getDataSourceInterfaceMock(), false, null], [$this->getOrmDataSourceInterfaceMock(), true, DBALException::driverExceptionDuringQuery(new \Exception('failed'), 'sql')], [$this->getOrmDataSourceInterfaceMock(), true, new InvalidConfigurationException()], [$this->getOrmDataSourceInterfaceMock(), true, null]];
 }
예제 #2
0
 public function testDoctrineExceptionFailedTransaction()
 {
     $db = $this->db();
     $ex = new \PDOException('SQLSTATE[25P02]: In failed sql transaction: 7 ERROR:  current transaction is aborted, commands ignored until end of transaction block');
     $first = DBALException::driverExceptionDuringQuery($ex, 'SELECT * FROM auth_users WHERE ok = ?', $db->resolveParams(array(1), array()));
     $second = DBALException::driverExceptionDuringQuery($ex, 'SELECT * FROM product WHERE id = ?', $db->resolveParams(array(2), array()));
     $firstContext = MonologBubble::exceptionContext($first);
     $secondContext = MonologBubble::exceptionContext($second);
     $this->assertNotEquals($firstContext, $secondContext);
     $this->assertEquals($this->loggerRecord($first), $this->loggerRecord($second));
 }
 /**
  * {@inheritdoc}
  */
 public function exec($statement)
 {
     $this->connect();
     $logger = $this->_config->getSQLLogger();
     if ($logger) {
         $logger->startQuery($statement);
     }
     try {
         $this->executeQuery($statement);
     } catch (\Exception $ex) {
         throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $statement);
     }
     if ($logger) {
         $logger->stopQuery();
     }
     return 1;
 }
예제 #4
0
파일: Statement.php 프로젝트: Dren-x/mobit
 /**
  * Executes the statement with the currently bound parameters.
  *
  * @param array|null $params
  *
  * @return boolean TRUE on success, FALSE on failure.
  *
  * @throws \Doctrine\DBAL\DBALException
  */
 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;
 }
예제 #5
0
 /**
  * Executes an SQL statement, returning a result set as a Statement object.
  *
  * @return \Doctrine\DBAL\Driver\Statement
  *
  * @throws \Doctrine\DBAL\DBALException
  */
 public function query()
 {
     $this->connect();
     $args = func_get_args();
     $logger = $this->_config->getSQLLogger();
     if ($logger) {
         $logger->startQuery($args[0]);
     }
     try {
         switch (func_num_args()) {
             case 1:
                 $statement = $this->_conn->query($args[0]);
                 break;
             case 2:
                 $statement = $this->_conn->query($args[0], $args[1]);
                 break;
             default:
                 $statement = call_user_func_array(array($this->_conn, 'query'), $args);
                 break;
         }
     } catch (\Exception $ex) {
         throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $args[0]);
     }
     $statement->setFetchMode($this->defaultFetchMode);
     if ($logger) {
         $logger->stopQuery();
     }
     return $statement;
 }
예제 #6
-1
 /**
  * Prepares an SQL statement.
  *
  * @param string $statement The SQL statement to prepare.
  * @throws DBALException
  * @return PDOStatement The prepared statement.
  */
 public function prepare($statement)
 {
     $this->connect();
     try {
         $stmt = new PDOStatement($statement, $this);
     } catch (\Exception $ex) {
         throw $this->resolveException(Doctrine\DBAL\DBALException::driverExceptionDuringQuery($this->getDriver(), $ex, $statement), $statement);
     }
     $stmt->setFetchMode(PDO::FETCH_ASSOC);
     return $stmt;
 }
예제 #7
-1
 public function testDriverExceptionDuringQueryAcceptsBinaryData()
 {
     $driver = $this->getMock('\\Doctrine\\DBAL\\Driver');
     $e = DBALException::driverExceptionDuringQuery($driver, new \Exception(), '', array('ABC', chr(128)));
     $this->assertContains('with params ["ABC", "\\x80"]', $e->getMessage());
 }