/** * 设置数据库的设置 * @param $config mixed a pear style dsn or an array * a dsn is like driver://username:password@localhost/dbname?option=a * current support driver 'mysql','mssql','mssqlnt' */ public function setConfig($config) { if (is_array($config)) { $this->config = $config; } elseif (!empty($config)) { $this->dsn = $config; $this->config = parse_dsn($this->dsn); } if (isset($this->config['autoclose'])) { $this->autoclose = $this->config['autoclose']; } }
/** * 获取系统日志数据库操作对象,当log_storage=database的时候会调用这个方法 * @return 返回到指定数据库的连接 */ function get_system_log_db_conn() { $app_config = get_app_config(); $db_config = parse_dsn($app_config->getGlobalConfig('system_log_db')); $db_helper = @mysql_connect($db_config['host'], $db_config['username'], $db_config['password']); @mysql_select_db($db_config['database'], $db_helper); return $db_helper; }