/** * Database connection * * @param bool $persistent * @return object */ public function db_connect($persistent = FALSE) { if (!empty($this->char_set) && preg_match('/utf[^8]*8/i', $this->char_set)) { $this->options[PDO::SQLSRV_ENCODING_UTF8] = 1; } $this->conn_id = parent::db_connect($persistent); if (!is_object($this->conn_id) or is_bool($this->_quoted_identifier)) { return $this->conn_id; } // Determine how identifiers are escaped $query = $this->query('SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi'); $query = $query->row_array(); $this->_quoted_identifier = empty($query) ? FALSE : (bool) $query['qi']; $this->_escape_char = $this->_quoted_identifier ? '"' : array('[', ']'); return $this->conn_id; }
/** * Database connection * * @param bool $persistent * @return object * @todo SSL support */ public function db_connect($persistent = FALSE) { /* Prior to PHP 5.3.6, even if the charset was supplied in the DSN * on connect - it was ignored. This is a work-around for the issue. * * Reference: http://www.php.net/manual/en/ref.pdo-mysql.connection.php */ if (!is_php('5.3.6') && !empty($this->char_set)) { $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . $this->char_set . (empty($this->dbcollat) ? '' : ' COLLATE ' . $this->dbcollat); } if ($this->stricton) { if (empty($this->options[PDO::MYSQL_ATTR_INIT_COMMAND])) { $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET SESSION sql_mode="STRICT_ALL_TABLES"'; } else { $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] .= ', @@session.sql_mode = "STRICT_ALL_TABLES"'; } } if ($this->compress === TRUE) { $this->options[PDO::MYSQL_ATTR_COMPRESS] = TRUE; } return parent::db_connect($persistent); }
/** * Database connection * * @param bool $persistent * @return object */ public function db_connect($persistent = FALSE) { $this->conn_id = parent::db_connect($persistent); if (is_object($this->conn_id) && !empty($this->schema)) { $this->simple_query('SET search_path TO ' . $this->schema . ',public'); } return $this->conn_id; }
/** * Database connection * * @param bool $persistent * @return object */ public function db_connect($persistent = FALSE) { $this->conn_id = parent::db_connect($persistent); if (!is_object($this->conn_id)) { return $this->conn_id; } // Determine how identifiers are escaped $query = $this->query('SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi'); $query = $query->row_array(); $this->_quoted_identifier = empty($query) ? FALSE : (bool) $query['qi']; $this->_escape_char = $this->_quoted_identifier ? '"' : array('[', ']'); return $this->conn_id; }