Example #1
0
 public function getEncontro()
 {
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     try {
         $db = new Zend_Db_Adapter_Pdo_Pgsql(array('host' => $config->resources->db->params->host, 'port' => $config->resources->db->params->port, 'username' => $config->resources->db->params->username, 'password' => $config->resources->db->params->password, 'dbname' => $config->resources->db->params->dbname));
         $id_encontro = $config->encontro->codigo;
         $sql = "\n            SELECT * FROM encontro WHERE id_encontro = ? ;\n            ";
         $this->encontro = $db->fetchRow($sql, $id_encontro);
     } catch (Exception $e) {
         throw new Exception("Erro ao se conectar com o banco de dados.<br>Detalhes: " . $e->getMessage());
     }
 }
Example #2
0
 public function testAdapterExceptionInvalidLoginCredentials()
 {
     $params = $this->_util->getParams();
     $params['password'] = '******';
     // invalid password
     try {
         $db = new Zend_Db_Adapter_Pdo_Pgsql($params);
         $db->getConnection();
         // force connection
         $this->fail('Expected to catch Zend_Db_Adapter_Exception');
     } catch (Zend_Exception $e) {
         $this->assertType('Zend_Db_Adapter_Exception', $e, 'Expecting object of type Zend_Db_Adapter_Exception, got ' . get_class($e));
     }
 }
Example #3
0
 /**
  * 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);
     }
 }
Example #4
0
 public function rollBack()
 {
     $this->_rollback = true;
     $this->_stack--;
     if ($this->_stack == 0) {
         $this->_rollback = false;
         parent::rollBack();
     }
 }
 /**
  * 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);
         }
     }
 }
Example #6
0
 public function query($sql, $bind = array())
 {
     logStd('query', 'using customer pgsql adapter');
     return parent::query($sql, $bind);
 }