function tearDown() { // drop test table $this->_db->query($this->getDropTableSQL()); // close the PDO connection $connection = $this->_db->getConnection(); $connection = null; $this->_db = null; }
/** * 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 }
/** * 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 }