Jagan Akash
Jagan Akash

Reputation: 559

How to use CONCAT in codeigniter datatable query?

I am using codeigniter framework, in this I was using datatable to generate values to view files. I need to CONCAT option to this query's. But when I use it shows 500 internal server errors. Below I have given the query.

 $this->load->library('datatables');

 $this->datatables
    ->select("sales.id as sid, CONCAT(sales.id, ' ',sales.export_status) as chid, date, reference_no, customer_name, note, delete_status, table_name, count, inv_total, inv_discount, total_tax2, total, internal_note");
 $this->datatables->join('order_table', 'order_table.id=sales.tableid', 'left');
 $this->datatables->from('sales'); 

I don't know what is the issue, I refereed so many links, but I cant get correct solution. Kindly guide me. Thanks in advance.

Upvotes: 2

Views: 1523

Answers (1)

Saty
Saty

Reputation: 22532

$this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.

  $this->datatables->select("sales.id as sid, CONCAT(sales.id, ' ',sales.export_status) as chid, date, reference_no, customer_name, note, delete_status, table_name, count, inv_total, inv_discount, total_tax2, total, internal_note",FALSE);

Upvotes: 3

Related Questions