1
我有以下控制器
controller
function bret($id){
$this->load->model('school_model');
$data = $this->school_model->get_city_and_population($id);
foreach ($data as $row)
{
echo "<b>Name Of The City</b>...........". $row['Name'];
echo "<br/>";
echo "<b>Total Population</b>...........".$row['Population'];
//echo "<a href='".$data->next_row()."'>next</a>";
}
}
和model
function get_city_and_population($id){
$this->db->select('Name,Population');
$query = $this->db->get_where('city', array('ID'=>$id));
return $query->result_array();
}
在我的數據庫,我使用的是ids
不連續,因爲我已經刪除了一些記錄。我將如何使用$row = $query->next_row()
去下一行?
我不認爲你可以在這種情況下使用'$ query-> next_row()',因爲這些函數是用於遍歷結果數組的。我認爲你提出了正確的方法,你只需要使用活動記錄類來構造你的查詢 –