我应用了所有可能的答案,但仍然是同样的问题。 也尝试了
$this->db->reconnect();
我的查询没有问题
mycode的:
public function GetdistributorsDetails($username){
$sql = "SELECT u.FirstName, u.Email, u.Telephone, u.MobileNumber, u.AlternateMobileNumber, ud.Address1, ud.Pincode,ud.City,s.Statename FROM users u JOIN userdetails ud ON ud.UserId = u.UserId JOIN states s ON s.StateId = ud.StateId WHERE u.Username = ? ";
$result = $this->db->query($sql,array($username));
return $result->result_array();
}
答案 0 :(得分:14)
将以下代码添加到/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;
答案 1 :(得分:3)
您可以在通话后使用此功能
mysqli_next_result( $this->db->conn_id );
答案 2 :(得分:0)
如果你在同一个函数中使用多个查询make,只需使用这个: $这 - > DB->关闭();
答案 3 :(得分:0)
如果存储过程返回多个结果,请尝试在查询之间添加以下代码:
$storedProcedure = 'CALL test(inputParam, @outputParam)';
$this->db->query($storedProcedure);
$conn = $this->db->conn_id;
do {
if ($result = mysqli_store_result($conn)) {
mysqli_free_result($result);
}
} while (mysqli_more_results($conn) && mysqli_next_result($conn));
$sql = 'SELECT @outputParam;';
$this->db->query($sql);
答案 4 :(得分:0)
只需在其中添加 next_result 函数 system\database\drivers\mysqli\mysqli_result.php 文件
public function next_result(){
if(is_object($this->conn_id) && mysqli_more_results($this->conn_id)){
return mysqli_next_result($this->conn_id);
}
}
调用查询函数
$result = $this->db->query("CALL {$Name}({$Q})",$Param);
$result->next_result();
return $result;
答案 5 :(得分:0)
Here is example if you don't want change any thing in mysqli drivers files
$sql = "CALL procedureName(IntParam,'VarcharParm1','VaracharParm2','VarcharParm3');";
$query = $this->db->query($sql);
mysqli_next_result( $this->db->conn_id );
$query->free_result();
these are important line place after to remove the error
mysqli_next_result( $this->db->conn_id );
$query->free_result();