CodeIgniter 3:错误号2014命令不同步;您现在无法运行此命令

时间:2017-02-19 06:10:44

标签: php mysql codeigniter-3

每次在CodeIgniter 3中调用第二个存储过程(insert_staff_logs)时,我都会收到MySQL错误号2014.

以下是生成的完整错误:

发生数据库错误

错误号码: 2014

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

CALL insert_staff_logs('1000',now(),'LOGIN')

文件名:C:/wamp/www/db2/system/database/DB_driver.php

行号: 691

这是我的模特:

class Login_model extends CI_Model
{
public function login($data)
{
    $query = $this->db->query("CALL login_auth('".$data['username']."','".$data['password']."')");
    if($query->num_rows() == 1)
    {
        return $query->result();
    }else
    {
        return false;
    }
}

public function staff_logs($data)
{
    $query = $this->db->query("CALL insert_staff_logs('".$data."',now(),'LOGIN')");
}
}

这是我的存储过程:

DELIMITER $$

CREATE
/*[DEFINER = { user | CURRENT_USER }]*/
PROCEDURE `must_empc_db`.`insert_staff_logs`(id VARCHAR(10),s VARCHAR(50))

BEGIN
INSERT INTO tblstafflogs(`staffID`,`timestamp`,`session`)
VALUES(id,NOW(),s);
END$$

DELIMITER ;

有没有人对此有解决方案?非常感谢您的回复。谢谢!

1 个答案:

答案 0 :(得分:0)

class Login_model extends CI_Model
{
    public function login($data)
    {        
        if (mysqli_more_results($this->db->conn_id)) {
            mysqli_next_result($this->db->conn_id);
        }
        $query = $this->db>query("CALLlogin_auth('".$data['username']."','".$data['password']."')");
        if($query->num_rows() == 1)
        {
            return $query->result();
        }
        else
        {
            return false;
        }
    }

    public function staff_logs($data)
    {
        if (mysqli_more_results($this->db->conn_id)) {
            mysqli_next_result($this->db->conn_id);
        }
        $query = $this->db->query("CALL insert_staff_logs('".$data."',now(),'LOGIN')");
    }
}