/** * 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); } }
/** * 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(); }
/** * Creates a PDO object and connects to the database. * * The IBM data server is set. * Current options are DB2 or IDS * @todo also differentiate between z/OS and i/5 * * @return void * @throws JO_Db_Adapter_Exception */ public function _connect() { if ($this->_connection) { return; } parent::_connect(); $this->getConnection()->setAttribute(JO_Db::ATTR_STRINGIFY_FETCHES, true); try { if ($this->_serverType === null) { $server = substr($this->getConnection()->getAttribute(PDO::ATTR_SERVER_INFO), 0, 3); switch ($server) { case 'DB2': $this->_serverType = new JO_Db_Adapter_Pdo_Ibm_Db2($this); // Add DB2-specific numeric types $this->_numericDataTypes['DECFLOAT'] = JO_Db::FLOAT_TYPE; $this->_numericDataTypes['DOUBLE'] = JO_Db::FLOAT_TYPE; $this->_numericDataTypes['NUM'] = JO_Db::FLOAT_TYPE; break; case 'IDS': $this->_serverType = new JO_Db_Adapter_Pdo_Ibm_Ids($this); // Add IDS-specific numeric types $this->_numericDataTypes['SERIAL'] = JO_Db::INT_TYPE; $this->_numericDataTypes['SERIAL8'] = JO_Db::BIGINT_TYPE; $this->_numericDataTypes['INT8'] = JO_Db::BIGINT_TYPE; $this->_numericDataTypes['SMALLFLOAT'] = JO_Db::FLOAT_TYPE; $this->_numericDataTypes['MONEY'] = JO_Db::FLOAT_TYPE; break; } } } catch (PDOException $e) { /** @see JO_Db_Adapter_Exception */ require_once 'JO/Db/Adapter/Exception.php'; $error = strpos($e->getMessage(), 'driver does not support that attribute'); if ($error) { throw new JO_Db_Adapter_Exception("PDO_IBM driver extension is downlevel. Please use driver release version 1.2.1 or later", 0, $e); } else { throw new JO_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e); } } }
/** * @return void */ protected function _connect() { if ($this->_connection) { return; } parent::_connect(); $this->_connection->exec('SET QUOTED_IDENTIFIER ON'); }
/** * 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]); } }