【问题标题】:Error when calling procedures in code igniter在 codeigniter 中调用过程时出错
【发布时间】:2016-01-17 06:01:55
【问题描述】:

我在代码点火器中调用一个过程,当我尝试调用另一个过程时出现以下错误:

错误号:2014

命令不同步;你现在不能运行这个命令

调用 get_post_info($id)

文件名:C:/Apache24/htdocs/application/models/Posts_model.php

行号:18

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

这是我的模型:

<?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));
}

【问题讨论】:

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

标签: codeigniter stored-procedures


【解决方案1】:

我实际上并没有运行这些解决方案,但我发现了一些您可能正在寻找的信息。首先,检查this post关于问题的原因。

我想$query-&gt;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 可能是 CodeIgniter 的一个很好的解决方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-21
    • 2015-09-02
    • 2014-07-15
    • 2011-12-07
    • 1970-01-01
    • 2013-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多