stop escaping column name codeigniter active recor

2019-09-08 03:03发布

问题:

I have following activerecord code to get invoice and sum of its payment.

$this->db->select('invoice.*,customer.custid,customer.cust_name,customer.cperson,customer.cust_email,customer.cust_mobile,customer.cust_address,sum(payment_received.amount) as paid_amount');
            $this->db->join('customer','customer.custid=invoice.custid');
            $this->db->join('payment_received','invoice.inid=payment_received.inid','left');
    $this->db->where('@paid_amount IS NULL');

Because of codeigniter escape column name with '`' this char its showing error "Unknown column '@paid_amount' in 'where clause'"

How to stop escaping of column name ??

回答1:

Have you looked at the User Guide? Both the get and where methods accept a parameter to prevent CI from escaping the data.

https://ellislab.com/codeIgniter/user-guide/database/active_record.html