所以在它没有像这样的错误之前,但是当我在我的数据库中创建了两个存储过程并在我的模型中调用它时。它在我的模型中出错了另一个函数。它没有错误我称之为程序的功能。它错误的另一个函数是我在模型中编写原始sql(Codelgniter)。
我的错误
我的模特
public function CheckProductInsert($company_id,$purchase_or_id,$product_id,$supplier_id){
$company_id = $this->db->escape_str($company_id);
$purchase_or_id = $this->db->escape_str($purchase_or_id);
$product_id = $this->db->escape_str($product_id);
$supplier_id = $this->db->escape_str($supplier_id);
$k="SELECT id
FROM gacc_purchases_or_details
WHERE
purchase_or_id=$purchase_or_id
AND product_id=$product_id
AND supplier_id=$supplier_id
AND company_id=$company_id
AND activate=1";
$re = $this->db->query($k);
if($re->num_rows() > 0){
return true;
}else{
return false;
}
}
我的控制器
if($this->PurchaseOrders->CheckProductInsert(
$this->security->xss_clean($this->company_id),
$this->security->xss_clean($purchase_order_id),
$this->security->xss_clean($product_id),
$this->security->xss_clean($supplier_id)
)==false){
echo json_encode(
array(
'status'=>false,
'message'=>'good job'
)
);
}else{
if($lang=='EN'){
echo json_encode(
array(
'status'=>false,
'message'=>'This product you have been add already.'
)
);
}else{
echo json_encode(
array(
'status'=>false,
'message'=>'ផលិតផល ដែលលោកអ្នករក្សាទុក បានបញ្ចូលរួចហើយ'
)
);
}
}
答案 0 :(得分:3)
如果您在此代码中使用了存储过程,则可能是解决方案
供参考 - link
解决方案:
将以下代码添加到/system/database/drivers/mysqli/mysqli_result.php
function next_result()
{
if (is_object($this->conn_id))
{
return mysqli_next_result($this->conn_id);
}
}
然后在模型中调用存储过程
$query = $this->db->query("CALL test()");
$res = $query->result();
//add this two line
$query->next_result();
$query->free_result();
//end of new code
return $res;
或者如果您不想编辑系统文件,请在调用存储过程时在模型中尝试此操作
mysqli_next_result( $this->db->conn_id );
$query->free_result();