2015-10-19 63 views
0

调用过程我打电话代码点火器的程序,当我尝试打电话给另外一个程序,我得到以下错误:错误时在代码点火器

Error Number: 2014

Commands out of sync; you can't run this command now

call get_post_info($id)

Filename: C:/Apache24/htdocs/application/models/Posts_model.php

Line Number: 18

我想我需要清除结果集.. 。 不确定。

Here is my model : 

<?php class Posts_model extends CI_Model { 

     public function __construct() 
     { 
       $this->load->database(); 
     } 

    public function get_post_ids($acc_id){ 

     $query = $this->db->query('call get_post_ids('.$this->db->escape($acc_id).')'); 
     return $query->row_array(); 
    } 


    public function get_post($id) 
     { 

       $query = $this->db->query('call get_post_info($id)'); 
       return $query->row_array(); 
     } 

} 

在我的控制器:

$post_ids = $this->posts_model->get_post_ids(1); 
     foreach ($post_ids as $id){ 

      array_push($data, $this->posts_model->get_post($id)); 
     } 
+0

你能用你的模型函数编辑你的问题吗 – user4419336

回答

0

我其实没有运行这些解决方案,但我发现了一些信息,可能是你寻找什么。首先,检查this post有关问题的原因。

我想$query->free_result()应该解决的问题:

public function get_post_ids($acc_id){ 
    $query = $this->db->query('call get_post_ids('.$this->db->escape($acc_id).')'); 
    $result = $query->row_array(); 
    $query->free_result(); 
    return $result; 
} 

而如果不工作,这this可能是笨了很好的解决。