从mysql迁移到mysqli - 问题

时间:2013-10-10 18:25:59

标签: mysql mysqli return

我有以下代码:

$query3 = "SELECT 
Office, 
COUNT(Office) As Tot_Part, 
(SELECT COUNT(Office) FROM trespondent WHERE completion_status= 'Started' OR completion_status = 'Complete') As Total_Resp 
FROM trespondent 
WHERE completion_status <> 'New' 
GROUP BY Office 
ORDER BY Office";

$result3 = $mysqli->query($query3);

我正试图从mysql转移到mysqli并且正在努力奋斗。上面的语句只返回1行,而不是应该存在的26。欢迎任何指示。

1 个答案:

答案 0 :(得分:2)

那是因为你只提取了一行($los = $result3->fetch_row();)。

循环试试。

编辑:像这样:

$result3 = $mysqli->query($query3); 
while($los = $result3->fetch_row())
 { 
 print_r($los); /* sanity */
 }