
“模型”和“控制器”内的代码需要更改为包含如下所示的代码 –
“控制器”内
$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']
);
}
}
Inside the 'model'
翻译成中文为:
在 'model' 内部
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循环内调用存储过程的详细内容。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

评论(0)