本文整理汇总了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]];
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}