首页 > 解决方案 > getting error Call to a member function result() on boolean when i try to use group_by function in codeigniter

问题描述

When i try to use group_by function select query not working, and i am getting error Call to a member function result(), without group by query is working, i can't fix this issue ? can anyone please help me to resolve this issue ? here i have added my whole query

$query = $this->db->select('s.*,b.*,c.*,i.*')
                 ->from('sales s')
                 ->join('biller b','s.biller_id=b.biller_id','inner')
                 ->join('customer c','s.customer_id=c.customer_id','inner')
                 ->join('invoice i ','s.sales_id=i.sales_id','inner')
                         ->group_by('sales_id');
        $data = $query->get()->result();
                return $data;

标签: codeigniter

解决方案


My guess is the sales_id column name on this line is ambiguous :

->group_by('sales_id');

So you could change it either using sales.sales_id or invoice.sales_id :

->group_by('s.sales_id');

推荐阅读