今天我发现我的更新功能突然在 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 引起的?