當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DBALException::driverExceptionDuringQuery方法代碼示例

本文整理匯總了PHP中Doctrine\DBAL\DBALException::driverExceptionDuringQuery方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBALException::driverExceptionDuringQuery方法的具體用法?PHP DBALException::driverExceptionDuringQuery怎麽用?PHP DBALException::driverExceptionDuringQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\DBAL\DBALException的用法示例。


在下文中一共展示了DBALException::driverExceptionDuringQuery方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validateDataProvider

 /**
  * @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]];
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:7,代碼來源:QueryValidatorTest.php

示例2: testDoctrineExceptionFailedTransaction

 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));
 }
開發者ID:Magomogo,項目名稱:monolog-bubble,代碼行數:11,代碼來源:MonologBubbleTest.php

示例3: exec

 /**
  * {@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;
 }
開發者ID:perfect-web,項目名稱:cassandra-doctrine,代碼行數:20,代碼來源:ConnectionWrapper.php

示例4: execute

 /**
  * 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;
 }
開發者ID:Dren-x,項目名稱:mobit,代碼行數:33,代碼來源:Statement.php

示例5: query

 /**
  * 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;
 }
開發者ID:BozzaCoon,項目名稱:SPHERE-Framework,代碼行數:36,代碼來源:Connection.php

示例6: prepare

 /**
  * 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;
 }
開發者ID:LidskaSila,項目名稱:Doctrine,代碼行數:18,代碼來源:Connection.php

示例7: testDriverExceptionDuringQueryAcceptsBinaryData

 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());
 }
開發者ID:selimcr,項目名稱:servigases,代碼行數:6,代碼來源:DBALExceptionTest.php


注:本文中的Doctrine\DBAL\DBALException::driverExceptionDuringQuery方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。