mysql_fetch_array返回错误的行计数


mysql_fetch_array returns wrong rows count

我有这个代码:

public function getRecurringEventsByGrouped($grouped){
    $query = "SELECT * FROM `event` AS e
    WHERE e.`grouped` = " . $grouped . " ORDER BY EventId DESC";
    $result = mysql_query($query);
    while ($ids[] = mysql_fetch_array($result, MYSQL_NUM)) ;
    return $ids;
}

mysql_fetch_array() 不会返回第一行。 mysql_num_rows()返回正确的行计数。

我也在HeidiSQL中尝试了这个查询,它给出了与mysql_num_rows()相同的行号。

您需要

遍历while循环中的数据。

$ids = '';
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
   //check for proper indexing of table rows and specify $row[value] accordingly.
   $ids[] = $row[0];
}
return $ids;

这应该会为您提供正确的内容。