public function testDbAdapterExceptionInvalidLoginCredentials() { $params = $this->_util->getParams(); $params['password'] = '******'; // invalid password try { $db = new Zend_Db_Adapter_Pdo_Oci($params); $db->getConnection(); // force connection $this->fail('Expected to catch Zend_Db_Adapter_Exception'); } catch (Exception $e) { $this->assertThat($e, $this->isInstanceOf('Zend_Db_Adapter_Exception'), 'Expecting object of type Zend_Db_Adapter_Exception, got ' . get_class($e)); } }
/** * Inserts a table row with specified data. * * @param mixed $table The table to insert data into. * @param array $bind Column-value pairs. * @return int The number of affected rows. */ public function insert($table = null, array $bind = null) { if (is_null($table) && is_null($bind)) { return new Harmoni_Db_Insert($this); } else { return parent::insert($table, $bind); } }
/** * Checks if the required options have been provided into the $config array * * @param array $config array of options * @return void * @throws Streamwide_Db_Adapter_Exception */ protected function _checkRequiredOptions(array $config) { if (!array_key_exists('host', $config)) { require_once 'Streamwide/Db/Adapter/Exception.php'; throw new Streamwide_Db_Adapter_Exception("Configuration array must have a key for 'host' naming the hostname or ip of the database server for mysql or the service name for oracle"); } parent::_checkRequiredOptions($config); }
/** * Creates a PDO object and connects to the database. * * @return void * @throws Zend_Db_Adapter_Exception */ protected function _connect() { if ($this->_connection) { return; } parent::_connect(); if (isset($this->_config['options']['init_commands']) && is_array($this->_config['options']['init_commands'])) { foreach ($this->_config['options']['init_commands'] as $sqlInitCommand) { $this->_connection->exec($sqlInitCommand); } } }