Esempio n. 1
0
 /**
  * Creates a PDO object and connects to the database.
  *
  * @return void
  * @throws JO_Db_Adapter_Exception
  */
 protected function _connect()
 {
     if ($this->_connection) {
         return;
     }
     parent::_connect();
     if (!empty($this->_config['charset'])) {
         $sql = "SET NAMES '" . $this->_config['charset'] . "'";
         $this->_connection->exec($sql);
     }
 }
Esempio n. 2
0
 /**
  * Creates a PDO object and connects to the database.
  *
  * @return void
  * @throws JO_Db_Adapter_Exception
  */
 protected function _connect()
 {
     if ($this->_connection) {
         return;
     }
     if (!empty($this->_config['charset'])) {
         $initCommand = "SET NAMES '" . $this->_config['charset'] . "'";
         $this->_config['driver_options'][1002] = $initCommand;
         // 1002 = PDO::MYSQL_ATTR_INIT_COMMAND
     }
     parent::_connect();
 }
Esempio n. 3
0
 /**
  * @return void
  */
 protected function _connect()
 {
     if ($this->_connection) {
         return;
     }
     parent::_connect();
     $this->_connection->exec('SET QUOTED_IDENTIFIER ON');
 }
Esempio n. 4
0
 /**
  * Special configuration for SQLite behavior: make sure that result sets
  * contain keys like 'column' instead of 'table.column'.
  *
  * @throws JO_Db_Adapter_Exception
  */
 protected function _connect()
 {
     /**
      * if we already have a PDO object, no need to re-connect.
      */
     if ($this->_connection) {
         return;
     }
     parent::_connect();
     $retval = $this->_connection->exec('PRAGMA full_column_names=0');
     if ($retval === false) {
         $error = $this->_connection->errorInfo();
         /** @see JO_Db_Adapter_Exception */
         require_once 'JO/Db/Adapter/Exception.php';
         throw new JO_Db_Adapter_Exception($error[2]);
     }
     $retval = $this->_connection->exec('PRAGMA short_column_names=1');
     if ($retval === false) {
         $error = $this->_connection->errorInfo();
         /** @see JO_Db_Adapter_Exception */
         require_once 'JO/Db/Adapter/Exception.php';
         throw new JO_Db_Adapter_Exception($error[2]);
     }
 }
Esempio n. 5
0
 /**
  * Inserts a table row with specified data.
  * Special handling for PDO_IBM
  * remove empty slots
  *
  * @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, array $bind)
 {
     $this->_connect();
     $newbind = array();
     if (is_array($bind)) {
         foreach ($bind as $name => $value) {
             if ($value !== null) {
                 $newbind[$name] = $value;
             }
         }
     }
     return parent::insert($table, $newbind);
 }