public db_connect ( boolean $persistent = FALSE ) : object | ||
$persistent | boolean | |
return | object |
public function db_connect($persistent = FALSE)
{
$this->options[PDO::ATTR_PERSISTENT] = $persistent;
try {
return new PDO($this->dsn, $this->username, $this->password, $this->options);
} catch (PDOException $e) {
if ($this->db_debug && empty($this->failover)) {
$this->display_error($e->getMessage(), '', TRUE);
}
return FALSE;
}
}
/** * Non-persistent database connection * * @param bool * @return object */ 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); } return parent::db_connect($persistent); }