2015-09-04 73 views
2

我正在使用codeigniter框架,在此我使用數據表生成值來查看文件。我需要CONCAT選項來查詢這個。但是,當我使用它顯示500內部服務器錯誤。下面我給出了查詢。如何在codeigniter數據表查詢中使用CONCAT?

$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'); 

我不知道是什麼問題,我推薦了這麼多的鏈接,但我不能得到正確的解決方案。請引導我。提前致謝。

+0

500內部服務器錯誤將從您的腳本,由於重定向 –

+0

但是,當我刪除查詢中的CONCAT選項意味着它工作正常。 –

+2

加上',FALSE);'最後在你的查詢中試試 – Saty

回答

3

$this->db->select()接受可選的第二參數。如果將其設置爲FALSE,則CodeIgniter不會嘗試使用反引號來保護字段或表名。如果您需要複合選擇語句,這很有用。

$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); 
+0

編輯$ this-> datatables-> select();缺少選擇拼寫。 –

+0

哦,謝謝你指出這個 – Saty

相關問題