在foreach PHP Codeigniter内部调用存储过程
需要更改“模型”和“控制器”内部的代码,以包括如下所示的代码:
在“控制器”内部
$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;
}热门推荐
10 动心的生日祝福语简短
11 婆婆生日祝福语短语简短
12 学生节祝福语简短大全
13 圣诞饭店祝福语大全简短
14 美丽晚霞祝福语简短句
15 简短长辈新年祝福语
16 英语简短祝福语给学生
17 夸赞老师祝福语搞笑简短
18 浪漫的生日祝福语简短