在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 婆婆66岁祝福语简短
13 今天孩子高考祝福语简短
14 送彩票生日祝福语简短
15 分别祝福语简短情话英文
16 画室揭牌仪式祝福语简短
17 女友妈妈生日祝福语简短
18 离别赠言离职祝福语简短