-1
今天我發現我的更新函數突然在codeigniter不能正常工作。我通過調用foreach循環兩次解決了這個問題,這裏是我的代碼:Codeigniter foreach工程奇怪
function _update($options = array(),$set = array()) {
......
foreach ($this->db->field_data($options['table']) as $field) {
//never get inside this foreach loop, but if I removed this foreach loop it will not get inside the next foreach loop.
}
foreach ($this->db->field_data($options['table']) as $field) {
if(isset($options[$field->name])) $this->db->where($field->name, $options[$field->name]);
if(isset($set[$field->name])) $this->db->set($field->name, $set[$field->name]);
}
......
}
這是codeigniter或PHP引起的問題嗎?
你是否在這個foreach上面操作數組?有沒有需要重置的內部指針? – dmayo
需要更多的代碼和澄清什麼「不正確」意味着 – ekims