当前位置: 首页>>代码示例>>PHP>>正文


PHP DBAL\DBALException类代码示例

本文整理汇总了PHP中Doctrine\DBAL\DBALException的典型用法代码示例。如果您正苦于以下问题:PHP DBALException类的具体用法?PHP DBALException怎么用?PHP DBALException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DBALException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的Doctrine\DBAL\DBALException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。