【发布时间】:2017-10-21 16:33:32
【问题描述】:
我试图让代码更好更干净。
工作但看起来很糟糕。 => http://wklej.org/id/3275269/
现在我试着让它变得更好。
$db = $this->database[GDB];
$message = '';
$num_rows = $db->doQuery('SELECT strUserID FROM USERDATA WHERE AUTHORITY=0');
if ($num_rows == -1)
{
$this->Error('DB_ERROR');
$db->getError();
return;
}
else if($num_rows == NULL){
$message = '<h3 class="error">List of Game Master is empty.</h3>';
}
$content = '';
while($result = $db->doRead()){
$gm = $result['strUserID'];
$query = $db->doQuery('select count(*) from CURRENTUSER where strCharID=?', $gm);
$row = $db->doRead();
if($query == 1)
$data['Status']='Online';
else
$data['Status']='Offline';
$content .= Template::Load('gmonline-1', array(
'name' => $gm,
'char_status' => $data['Status'])
);
} //End while
$this->content = Template::Load('gmonline', array(
'GM_LIST' => $content,
'message' => $message
));
它不显示错误,但不显示所有 GM LIST。
【问题讨论】:
-
你能说得清楚一点吗? “看起来很糟糕”的代码实际上比这更干净。但我仍然不知道你想要什么
-
感谢 asnwer,因为我想显示 Game Master List (Nick + status) with function while,但是 num_rows 不会像我想要的那样工作,因为我不知道如何使用它
-
我不知道的东西太多了。对象
$db是什么?从方法来看,我会说你使用的是 mongo DB,但是查询是用 SQL 进行的。 -
再次感谢您的回答,wklej.org/id/3275281 它的方法