本文整理汇总了PHP中Doctrine\DBAL\DBALException类的典型用法代码示例。如果您正苦于以下问题:PHP DBALException类的具体用法?PHP DBALException怎么用?PHP DBALException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DBALException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: connect
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
try {
$pdo = new PDOConnection($this->_constructPdoDsn($params), $username, $password, $driverOptions);
if (PHP_VERSION_ID >= 50600 && (!isset($driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES]) || true === $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES])) {
$pdo->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true);
}
return $pdo;
} catch (PDOException $e) {
throw DBALException::driverException($this, $e);
}
}
开发者ID:ccq18,项目名称:EduSoho,代码行数:15,代码来源:Driver.php
示例2: isDuplicateException
/**
* Only tested with PDO
*
* @param DBALException $error
* @return bool
*/
public function isDuplicateException(DBALException $error)
{
/** @var \PDOException $previous */
$previous = $error->getPrevious();
if (!$previous || $previous->getCode() != 23505) {
return false;
}
return true;
}
开发者ID:thewunder,项目名称:corma,代码行数:15,代码来源:PostgreSQLQueryHelper.php
示例3: isDuplicateException
/**
* Only tested with PDO
*
* @param DBALException $error
* @return bool
*/
public function isDuplicateException(DBALException $error)
{
/** @var \PDOException $previous */
$previous = $error->getPrevious();
if (!$previous || $previous->getCode() != 23000) {
return false;
}
return isset($previous->errorInfo[1]) && $previous->errorInfo[1] == 1062;
}
开发者ID:thewunder,项目名称:corma,代码行数:15,代码来源:MySQLQueryHelper.php
示例4: writeLimitClause
/**
* Adds an adapter-specific LIMIT clause to the SELECT statement.
* [ borrowed from Zend Framework ]
*
* @param string $query
* @param mixed $limit
* @param mixed $offset
* @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html
* @return string
* @override
*/
public function writeLimitClause($query, $limit = false, $offset = false)
{
if ($limit > 0) {
$count = intval($limit);
$offset = intval($offset);
if ($offset < 0) {
throw DBALException::limitOffsetInvalid($offset);
}
$orderby = stristr($query, 'ORDER BY');
if ($orderby !== false) {
$sort = stripos($orderby, 'desc') !== false ? 'desc' : 'asc';
$order = str_ireplace('ORDER BY', '', $orderby);
$order = trim(preg_replace('/ASC|DESC/i', '', $order));
}
$query = preg_replace('/^SELECT\\s/i', 'SELECT TOP ' . ($count + $offset) . ' ', $query);
$query = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $query . ') AS inner_tbl';
if ($orderby !== false) {
$query .= ' ORDER BY ' . $order . ' ';
$query .= stripos($sort, 'asc') !== false ? 'DESC' : 'ASC';
}
$query .= ') AS outer_tbl';
if ($orderby !== false) {
$query .= ' ORDER BY ' . $order . ' ' . $sort;
}
return $query;
}
return $query;
}
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:39,代码来源:MsSqlPlatform.php
示例5: connect
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
try {
return new MysqliConnection($params, $username, $password, $driverOptions);
} catch (MysqliException $e) {
throw DBALException::driverException($this, $e);
}
}
开发者ID:kierkegaard13,项目名称:graph-generator,代码行数:11,代码来源:Driver.php
示例6: connect
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
try {
return new PDOConnection($this->constructPdoDsn($params), $username, $password, $driverOptions);
} catch (\PDOException $e) {
throw DBALException::driverException($this, $e);
}
}
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:11,代码来源:Driver.php
示例7: connect
/**
* {@inheritdoc}
*
* @throws \Doctrine\DBAL\DBALException if there was a problem establishing the connection.
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
try {
return new SQLAnywhereConnection($this->buildDsn(isset($params['host']) ? $params['host'] : null, isset($params['port']) ? $params['port'] : null, isset($params['server']) ? $params['server'] : null, isset($params['dbname']) ? $params['dbname'] : null, $username, $password, $driverOptions), isset($params['persistent']) ? $params['persistent'] : false);
} catch (SQLAnywhereException $e) {
throw DBALException::driverException($this, $e);
}
}
开发者ID:Dren-x,项目名称:mobit,代码行数:13,代码来源:Driver.php
示例8: connect
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = NULL, $password = NULL, array $driverOptions = [])
{
try {
// create our special driver
$conn = new PDOConnection($this->constructPdoDsn($params), $username, $password, $driverOptions);
} catch (PDOException $e) {
throw DBALException::driverException($this, $e);
}
return $conn;
}
开发者ID:RadekDvorak,项目名称:modular-testcase,代码行数:13,代码来源:MySqlDriver.php
示例9: 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
示例10: connect
/**
* {@inheritdoc}
*
* @throws \Doctrine\DBAL\DBALException if there was a problem establishing the connection.
* @throws SQLAnywhereException if a mandatory connection parameter is missing.
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
if (!isset($params['host'])) {
throw new SQLAnywhereException("Missing 'host' in configuration for sqlanywhere driver.");
}
if (!isset($params['server'])) {
throw new SQLAnywhereException("Missing 'server' in configuration for sqlanywhere driver.");
}
if (!isset($params['dbname'])) {
throw new SQLAnywhereException("Missing 'dbname' in configuration for sqlanywhere driver.");
}
try {
return new SQLAnywhereConnection($this->buildDsn($params['host'], isset($params['port']) ? $params['port'] : null, $params['server'], $params['dbname'], $username, $password, $driverOptions), isset($params['persistent']) ? $params['persistent'] : false);
} catch (SQLAnywhereException $e) {
throw DBALException::driverException($this, $e);
}
}
开发者ID:jay45,项目名称:porn,代码行数:23,代码来源:Driver.php
示例11: __construct
/**
* @param string $tableName
* @param Column[] $columns
* @param Index[] $indexes
* @param ForeignKeyConstraint[] $fkConstraints
* @param integer $idGeneratorType
* @param array $options
*
* @throws DBALException
*/
public function __construct($tableName, array $columns = array(), array $indexes = array(), array $fkConstraints = array(), $idGeneratorType = 0, array $options = array())
{
if (strlen($tableName) == 0) {
throw DBALException::invalidTableName($tableName);
}
$this->_setName($tableName);
foreach ($columns as $column) {
$this->_addColumn($column);
}
foreach ($indexes as $idx) {
$this->_addIndex($idx);
}
foreach ($fkConstraints as $constraint) {
$this->_addForeignKeyConstraint($constraint);
}
$this->_options = $options;
}
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:27,代码来源:Table.php
示例12: 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
示例13: createDatabasePlatformForVersion
/**
* {@inheritdoc}
*/
public function createDatabasePlatformForVersion($version)
{
if (!preg_match('/^(?P<major>\\d+)(?:\\.(?P<minor>\\d+)(?:\\.(?P<patch>\\d+))?)?/', $version, $versionParts)) {
throw DBALException::invalidPlatformVersionSpecified($version, '<major_version>.<minor_version>.<patch_version>');
}
$majorVersion = $versionParts['major'];
$minorVersion = isset($versionParts['minor']) ? $versionParts['minor'] : 0;
$patchVersion = isset($versionParts['patch']) ? $versionParts['patch'] : 0;
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
switch (true) {
case version_compare($version, '9.2', '>='):
return new PostgreSQL92Platform();
case version_compare($version, '9.1', '>='):
return new PostgreSQL91Platform();
default:
return new PostgreSqlPlatform();
}
}
开发者ID:hilmysyarif,项目名称:l4-bootstrap-admin,代码行数:21,代码来源:AbstractPostgreSQLDriver.php
示例14: connect
/**
* {@inheritdoc}
*/
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
try {
$pdo = new PDOConnection($this->_constructPdoDsn($params), $username, $password, $driverOptions);
if (defined('PDO::PGSQL_ATTR_DISABLE_PREPARES') && (!isset($driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES]) || true === $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES])) {
$pdo->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true);
}
/* defining client_encoding via SET NAMES to avoid inconsistent DSN support
* - the 'client_encoding' connection param only works with postgres >= 9.1
* - passing client_encoding via the 'options' param breaks pgbouncer support
*/
if (isset($params['charset'])) {
$pdo->query('SET NAMES \'' . $params['charset'] . '\'');
}
return $pdo;
} catch (PDOException $e) {
throw DBALException::driverException($this, $e);
}
}
开发者ID:vectornet,项目名称:dbal,代码行数:22,代码来源:Driver.php
示例15: createConnection
public function createConnection($config)
{
$driver = $this->driver_manager->driver(array_get($config, 'driver', ''));
if (!$driver instanceof \Doctrine\DBAL\Driver) {
$driver = $this->driver_manager->driver();
}
$params = $config;
$params['host'] = array_get($params, 'host', array_get($config, 'server'));
$params['user'] = array_get($params, 'user', array_get($config, 'username'));
$params['wrapperClass'] = array_get($config, 'wrapperClass', '\\Concrete\\Core\\Database\\Connection\\Connection');
unset($params['driver']);
$wrapperClass = 'Doctrine\\DBAL\\Connection';
if (isset($params['wrapperClass'])) {
if (is_subclass_of($params['wrapperClass'], $wrapperClass)) {
$wrapperClass = $params['wrapperClass'];
} else {
throw DBALException::invalidWrapperClass($params['wrapperClass']);
}
}
return new $wrapperClass($params, $driver);
}
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:21,代码来源:ConnectionFactory.php
示例16: createDatabasePlatformForVersion
/**
* {@inheritdoc}
*/
public function createDatabasePlatformForVersion($version)
{
if (!preg_match('/^(?P<major>\\d+)(?:\\.(?P<minor>\\d+)(?:\\.(?P<patch>\\d+)(?:\\.(?P<build>\\d+))?)?)?/', $version, $versionParts)) {
throw DBALException::invalidPlatformVersionSpecified($version, '<major_version>.<minor_version>.<patch_version>.<build_version>');
}
$majorVersion = $versionParts['major'];
$minorVersion = isset($versionParts['minor']) ? $versionParts['minor'] : 0;
$patchVersion = isset($versionParts['patch']) ? $versionParts['patch'] : 0;
$buildVersion = isset($versionParts['build']) ? $versionParts['build'] : 0;
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion . '.' . $buildVersion;
switch (true) {
case version_compare($version, '11.00.2100', '>='):
return new SQLServer2012Platform();
case version_compare($version, '10.00.1600', '>='):
return new SQLServer2008Platform();
case version_compare($version, '9.00.1399', '>='):
return new SQLServer2005Platform();
default:
return new SQLServerPlatform();
}
}
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:24,代码来源:AbstractSQLServerDriver.php
示例17: getIndexDeclarationSQL
/**
* {@inheritdoc}
*/
public function getIndexDeclarationSQL($name, Index $index)
{
// Index declaration in statements like CREATE TABLE is not supported.
throw DBALException::notSupported(__METHOD__);
}
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:8,代码来源:SQLAnywherePlatform.php
示例18: 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
示例19: createDatabasePlatformForVersion
/**
* {@inheritdoc}
*/
public function createDatabasePlatformForVersion($version)
{
if (!preg_match('/^(?P<major>\\d+)(?:\\.(?P<minor>\\d+)(?:\\.(?P<patch>\\d+))?)?/', $version, $versionParts)) {
throw DBALException::invalidPlatformVersionSpecified($version, '<major_version>.<minor_version>.<patch_version>');
}
if (false !== stripos($version, 'mariadb')) {
return $this->getDatabasePlatform();
}
$majorVersion = $versionParts['major'];
$minorVersion = isset($versionParts['minor']) ? $versionParts['minor'] : 0;
$patchVersion = isset($versionParts['patch']) ? $versionParts['patch'] : 0;
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
if (version_compare($version, '5.7', '>=')) {
return new MySQL57Platform();
}
return $this->getDatabasePlatform();
}
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:20,代码来源:AbstractMySQLDriver.php
示例20: _getPortableSequenceDefinition
/**
* @param array $sequence
* @return Sequence
*/
protected function _getPortableSequenceDefinition($sequence)
{
throw DBALException::notSupported('Sequences');
}
开发者ID:jff15,项目名称:travelbot,代码行数:8,代码来源:AbstractSchemaManager.php
注:本文中的Doctrine\DBAL\DBALException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论