本文整理汇总了PHP中Zend_Db_Adapter_Pdo_Abstract::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Adapter_Pdo_Abstract::getConnection方法的具体用法?PHP Zend_Db_Adapter_Pdo_Abstract::getConnection怎么用?PHP Zend_Db_Adapter_Pdo_Abstract::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Adapter_Pdo_Abstract
的用法示例。
在下文中一共展示了Zend_Db_Adapter_Pdo_Abstract::getConnection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
function tearDown()
{
// drop test table
$this->_db->query($this->getDropTableSQL());
// close the PDO connection
$connection = $this->_db->getConnection();
$connection = null;
$this->_db = null;
}
示例2: _zendConnect
/**
* Initialize Zend database adapter
*
* @param string $dbname The name of the database to connect with
*
* @throws ConfigurationError In case the resource type is not a supported PDO driver name
*/
protected function _zendConnect($dbname)
{
if ($this->zendConn !== null) {
return;
}
$config = array('dbname' => $dbname, 'host' => $this->config['host'], 'port' => $this->config['port'], 'username' => $this->config['username'], 'password' => $this->config['password']);
if ($this->config['db'] === 'mysql') {
if (isset($this->config['use_ssl']) && $this->config['use_ssl']) {
$this->config['driver_options'] = array();
# The presence of these keys as empty strings or null cause non-ssl connections to fail
if ($this->config['ssl_key']) {
$config['driver_options'][PDO::MYSQL_ATTR_SSL_KEY] = $this->config['ssl_key'];
}
if ($this->config['ssl_cert']) {
$config['driver_options'][PDO::MYSQL_ATTR_SSL_CERT] = $this->config['ssl_cert'];
}
if ($this->config['ssl_ca']) {
$config['driver_options'][PDO::MYSQL_ATTR_SSL_CA] = $this->config['ssl_ca'];
}
if ($this->config['ssl_capath']) {
$config['driver_options'][PDO::MYSQL_ATTR_SSL_CAPATH] = $this->config['ssl_capath'];
}
if ($this->config['ssl_cipher']) {
$config['driver_options'][PDO::MYSQL_ATTR_SSL_CIPHER] = $this->config['ssl_cipher'];
}
}
$this->zendConn = new Zend_Db_Adapter_Pdo_Mysql($config);
} elseif ($this->config['db'] === 'pgsql') {
$this->zendConn = new Zend_Db_Adapter_Pdo_Pgsql($config);
} else {
throw new ConfigurationError('Failed to connect to database. Unsupported PDO driver "%s"', $this->config['db']);
}
$this->zendConn->getConnection();
// Force connection attempt
}
示例3: _zendConnect
/**
* Initialize Zend database adapter
*
* @param string $dbname The name of the database to connect with
*
* @throws ConfigurationError In case the resource type is not a supported PDO driver name
*/
protected function _zendConnect($dbname)
{
if ($this->zendConn !== null) {
return;
}
$config = array('dbname' => $dbname, 'host' => $this->config['host'], 'port' => $this->config['port'], 'username' => $this->config['username'], 'password' => $this->config['password']);
if ($this->config['db'] === 'mysql') {
$this->zendConn = new Zend_Db_Adapter_Pdo_Mysql($config);
} elseif ($this->config['db'] === 'pgsql') {
$this->zendConn = new Zend_Db_Adapter_Pdo_Pgsql($config);
} else {
throw new ConfigurationError('Failed to connect to database. Unsupported PDO driver "%s"', $this->config['db']);
}
$this->zendConn->getConnection();
// Force connection attempt
}