我使用codeigniter和Gameq库。我对这个美丽的图书馆有一个问题: 我请求关于100个游戏服务器的数据,它返回关于86个服务器的数据。我请求数据约500个服务器,它返回有关86服务器的数据。 这是我的代码:
public function index()
{
//$results['data'] = $this->_get_servers_list();
//Trying to get cached servers list
if(!$this->cache->file->get('serverslist'))
{
//If no... cache it
$results['data'] = $this->_cache_servers_list();
}
else
{
//Else - get cached servers list from cached file
$results['data'] = unserialize($this->cache->file->get('serverslist'));
}
//print_r($results['data']);
$this->load->view('serverslist', $results);
}
public function _get_servers_list()
{
//Gettings servers from database
$query = $this->database->_get_server_list('servers', 100);
$data = $query->result();
$servers = array();
//Preparing servers list for GameQ
foreach($data as $result)
{
$servers[] = array(
'id' => $result->id,
'host' => $result->address,
'type' => 'cs16'
);
}
//Getting servers data with GameQ
$results = GameQ::factory()
->setOption('timeout', 5)
->setOption('debug', FALSE)
//->setOption('raw', true)
->setFilter('normalise')
->addServers($servers)
->requestData();
//Parsing offline servers
foreach($results as $id => $value)
{
if(!$results[$id]['gq_online'])
{
//unset($results[$id]);
//$results[$id]['gq_hostname'] = 'Server offline or changing map';
}
}
return $results;
}
public function _cache_servers_list()
{
//Getting servers list
$data = serialize($this->_get_servers_list());
//Caching servers list
$this->cache->file->save('serverslist', $data, 120);
return unserialize($data);
}
有人可以帮助我吗?