在添加 group_by() 时调用布尔值成员函数 result()

我正在使用 codeigniter 创建一个项目,所有模块在本地主机中都工作正常,但是当我在 AWS 上上传文件时,它显示错误,主要是不起作用,如果我删除group_by()此功能,它工作正常,请帮助,我添加了一些代码片段和表结构。


模型:


 public function getPendingPayments() {

    $this->db->where('is_paid', 0);

    $this->db->where('is_installment', 0);

    $this->db->group_by('party'); // here if I remove this line, everything works fine

    $this->db->order_by('bill_date', 'asc');

    return $this->db->get('bills')->result();

}

控制器:


$data['UNPAID_CLIENTS'] = $this->Payments_model->getPendingPayments();

表结构:

https://img1.sycdn.imooc.com/652b96920001f49906500450.jpg

错误:

https://img1.sycdn.imooc.com/652b96a00001a2ff05680342.jpg

拉莫斯之舞
浏览 87回答 2
2回答

FFIVE

试试这个&nbsp;public function getPendingPayments() {&nbsp; &nbsp; $this->db->where('is_paid', 0);&nbsp; &nbsp; $this->db->where('is_installment', 0);&nbsp; &nbsp; $this->db->group_by('party');&nbsp;&nbsp; &nbsp; $this->db->order_by('bill_date', 'asc');if($this->db->num_rows() < 1){return false;}else{&nbsp; &nbsp;return $this->db->get('bills')->result();&nbsp; &nbsp; return $this->db->get('bills')->result();}

慕婉清6462132

经过调查,我发现手动执行查询时mysql出现错误。&nbsp;所以我only_full_group_by通过在 SQL Server 中执行这一行来全局删除SET&nbsp;GLOBAL&nbsp;sql_mode=(SELECT&nbsp;REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
打开App,查看更多内容
随时随地看视频慕课网APP