问题是 $callback 的第一个维度永远不会超过第二个维度的长度。
例如,如果我添加一个其他字段,例如:
$callback[$counter]['field'] = $rec['filed'];
两个长度都将变为 6。我该如何解决这个问题?
public function returnAll(&$callback) {
$callback = array();
$counter = 0;
$this->db->query("SELECT * FROM `news` WHERE 1 ");
$rec = $this->db->NextRecord();
if (!($this->db->num_row() > 1))
return false;
while ( $rec ) {
$callback[$counter]['title'] = $rec['title'];
$callback[$counter]['text'] = $rec['text'];
$callback[$counter]['type'] = $rec['type'];
$callback[$counter]['abstract'] = $rec['abstract'];
$callback[$counter]['news_date'] = $rec['news_date'];
$rec = $this->db->NextRecord();
$counter++;
}
return true;
}