public function __construct($item) { if (empty($item)) { return $item; } $dbConf = Conf::getConf('/db/mysql/' . $item); $this->log = Log::getInstance('mysql'); $this->connect($dbConf["hostname"], $dbConf["username"], $dbConf["password"], $dbConf["database"], $dbConf["pconnect"]); }
public static function getInstance($name = '') { if (!$name) { $name = APP_NAME; } if (!self::$logId) { self::getLogId(); } if (!empty(self::$instance[$name])) { return self::$instance[$name]; } $logConf = Conf::getConf("/log/{$name}"); if (!isset($logConf['logLevel']) || !$logConf['logLevel']) { $logConf['logLevel'] = Conf::getConf("/log/logLevel"); } if (!isset($logConf['logLevel']) || !$logConf['logLevel']) { $logConf['logLevel'] = self::LOG_LEVEL_NOTICE; } if (!isset($logConf['file']) || !$logConf['file']) { $logConf['file'] = LOG_PATH . '/' . $name . '.log'; } self::$instance[$name] = new Log($logConf); return self::$instance[$name]; }
function Sphinx($name) { $sphinxConf = Conf::getConf('/sphinx/' . $name); $log = Log::getInstance('sphinx'); if (!$sphinxConf) { $log->warning('Sphinx not in conf, Name:' . $name); return false; } if (!$sphinxConf['host'] || !$sphinxConf['port']) { $log->warning('Sphinx Conf must have host and port'); return false; } $this->_host = $sphinxConf['host']; $this->_port = $sphinxConf['port']; $this->_path = false; $this->_socket = false; // per-query settings $this->_offset = 0; $this->_limit = 20; $this->_mode = SPH_MATCH_ALL; $this->_weights = array(); $this->_sort = SPH_SORT_RELEVANCE; $this->_sortby = ""; $this->_min_id = 0; $this->_max_id = 0; $this->_filters = array(); $this->_groupby = ""; $this->_groupfunc = SPH_GROUPBY_DAY; $this->_groupsort = "@group desc"; $this->_groupdistinct = ""; $this->_maxmatches = 1000; $this->_cutoff = 0; $this->_retrycount = 0; $this->_retrydelay = 0; $this->_anchor = array(); $this->_indexweights = array(); $this->_ranker = SPH_RANK_PROXIMITY_BM25; $this->_maxquerytime = 0; $this->_fieldweights = array(); $this->_overrides = array(); $this->_select = "*"; $this->_error = ""; // per-reply fields (for single-query case) $this->_warning = ""; $this->_connerror = false; $this->_reqs = array(); // requests storage (for multi-query case) $this->_mbenc = ""; $this->_arrayresult = false; $this->_timeout = 0; }