「模型」和「控制器」內的程式碼需要更改為包含如下所示的程式碼-
$header = $this->model_name->call_head(); foreach($header as $item) { $name = $item['name']; $array['name'] = $name; $array['data'] = $item['data']; $child_val = $this->model_name->call_child($name); foreach($child_val as $value) { $array['child'] = array( 'child_name' => $value['child_name'], 'child_data' => $value['child_data'] ); } }
public function call_head() { $query = "CALL PROCEDURE_HEAD()"; $result = $this->db->query($query)->result_array(); $query->next_result(); $query->free_result(); return $result; } public function call_child($name) { $query = "CALL PROCEDURE_CHILD($name)"; $result = $this->db->query($query)->result_array(); $query->next_result(); $query->free_result(); return $result; }
以上是在Codeigniter中的foreach迴圈內呼叫預存程序的詳細內容。更多資訊請關注PHP中文網其他相關文章!