本文整理汇总了PHP中Doctrine\DBAL\DBALException::driverException方法的典型用法代码示例。如果您正苦于以下问题:PHP DBALException::driverException方法的具体用法?PHP DBALException::driverException怎么用?PHP DBALException::driverException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\DBALException
的用法示例。
在下文中一共展示了DBALException::driverException方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: 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;
}
示例6: 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);
}
}
示例7: 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);
}
}
示例8: constructPdoDsn
/**
* Constructs the Informix PDO DSN.
*
* @param array $params
* @return string The DSN.
* @throws \Doctrine\DBAL\DBALException
* @see \Doctrine\DBAL\Driver::connect
*/
private function constructPdoDsn(array $params)
{
if (empty($params['dbname'])) {
throw DBALException::driverException($this, new \Exception("Missing 'dbname' in configuration for informix driver"));
}
if (empty($params['host'])) {
throw DBALException::driverException($this, new \Exception("Missing 'host' in configuration for informix driver"));
}
if (empty($params['protocol'])) {
throw DBALException::driverException($this, new \Exception("Missing 'protocol' in configuration for informix driver"));
}
if (empty($params['server'])) {
throw DBALException::driverException($this, new \Exception("Missing 'server' in configuration for informix driver"));
}
$dsn = 'informix:' . 'host=' . $params['host'] . ';' . 'server=' . $params['server'] . ';' . 'database=' . $params['dbname'] . ';' . 'protocol=' . $params['protocol'] . ';';
if (!empty($params['port'])) {
$dsn .= 'service=' . $params['port'] . ';';
}
return $dsn;
}