/** * * @param string $params * @return boolean */ function __construct($params) { parent::__construct($params); // mysqli connect if ($this->port == '') { $this->connection = new mysqli($this->hostname, $this->username, $this->password, $this->dbname); } else { $this->connection = new mysqli($this->hostname, $this->username, $this->password, $this->dbname, $this->port); } if ($this->connection->connect_error) { $this->debug(__CLASS__, $this->connection->connect_error); } else { $this->connection->set_charset($this->char_set); } }
/** * * @param string $params * @return boolean */ function __construct($params) { parent::__construct($params); // mysql connect $conn = @mysql_connect($this->hostname, $this->username, $this->password, true); if ($conn != false) { $db = @mysql_select_db($this->dbname, $conn); @mysql_query('SET NAMES ' . $this->char_set, $conn); } if ($conn == false || $db == false) { $this->debug(__CLASS__, mysql_error($this->connection)); return false; } else { $this->connection = $conn; return true; } }
/** * * @param string $params * @return boolean */ function __construct($params) { parent::__construct($params); // pdo options $options = array(); $options[PDO::ATTR_PERSISTENT] = true; $options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; if ($this->dbdriver == 'mysql') { $options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . $this->char_set; } // pdo connect try { // connection string $sql = $this->dbdriver . ':host=' . $this->hostname . ($this->dbname == '' ? '' : ';dbname=' . $this->dbname); // connect to database $this->connection = new PDO($sql, $this->username, $this->password, $options); } catch (PDOException $e) { $this->debug('PDO_DB_driver', $e->getMessage()); } }
public function __construct($params) { parent::__construct($params); }