/** * 初始化数据库 * * @param array $config 数据库配置 */ protected static function _init_mysql($config = array()) { if ($config == NULL) { $config = $GLOBALS['config']['db']; } if (!self::$db) { self::$db = new mysqli($config['host'], $config['user'], $config['password'], $config['db_name']); if (0 == self::$db->connect_errno) { self::$db->set_charset('utf8'); } else { echo 'MySQL connect error' . PHP_EOL; } } }