/** * Create the database connection, select the appropriate db and call setOptions * @param string $dbHost * @param string $dbUname * @param string $dbPass * @param string $dbName * @param string $dbPort * @return void */ public function initialize($dbHost, $dbUname, $dbPass, $dbName, $dbPort) { $this->connection = mysqli_init(); if (!$this->connection->options(MYSQLI_INIT_COMMAND, 'set names utf8, collation_connection=utf8_unicode_ci')) { trigger_error('MySQLi_options call failed'); } $this->connection->options(MYSQLI_OPT_CONNECT_TIMEOUT, 2); $this->connection->real_connect($dbHost, $dbUname, $dbPass, $dbName, $dbPort); $this->connection->set_charset('utf8'); if (mysqli_connect_errno()) { trigger_error('Unable to connect to MySQL: ' . mysqli_connect_error() . " H:'" . $_SERVER['HTTP_HOST'] . "'"); die; } $this->dbOnline = true; }