public static function getMysqli() { if (!isset(self::$_mysqli)) { $config = array_merge(array('host' => 'localhost', 'port' => 3306), Site::getConfig('mysql')); // connect to mysql database self::$_mysqli = @new mysqli($config['host'], $config['username'], $config['password'], $config['database'], $config['port'], $config['socket']); self::$_mysqli->set_charset('utf8'); // check for failure or connection error if (mysqli_connect_error()) { self::handleError('connect'); } // set timezone to match PHP self::nonQuery('SET time_zone = "%s"', self::escape(date('P'))); } return self::$_mysqli; }
public static function getMysqli() { if (!isset(self::$_mysqli)) { // connect to mysql database self::$_mysqli = @new mysqli(Site::$databaseHost, Site::$databaseUsername, Site::$databasePassword, Site::$databaseName); // check for failure or connection error if (mysqli_connect_error()) { self::handleError('connect'); } // set timezone if (isset(self::$TimeZone)) { self::$_mysqli->query(sprintf('SET time_zone = "%s"', self::$_mysqli->real_escape_string(self::$TimeZone))); } } return self::$_mysqli; }