/** * Creates a PDO object and connects to the database. * * @return void * @throws \Zend\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(); }
/** * Special configuration for SQLite behavior: make sure that result sets * contain keys like 'column' instead of 'table.column'. * * @throws \Zend\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(); throw new Adapter\Exception($error[2]); } $retval = $this->_connection->exec('PRAGMA short_column_names=1'); if ($retval === false) { $error = $this->_connection->errorInfo(); throw new Adapter\Exception($error[2]); } }