From 8da106169e12db12543d5f03c26e59de8a3a7c90 Mon Sep 17 00:00:00 2001 From: xtreme8888 Date: Thu, 10 Nov 2016 09:24:32 +1100 Subject: [PATCH] Sorting for appendToSelectStr field DB error Ordering by appendToSelectStr field causing DB error in Codeigniter 3.1.0, haven't tested on other version. Resolution: To use original colname with removed $. should do the trick. Current version uses $colName = $customExpArray[$aliasKey]; causing DB append sorting method to end of each concat individual value --- libraries/Datatable.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libraries/Datatable.php b/libraries/Datatable.php index d7f2363..297702a 100644 --- a/libraries/Datatable.php +++ b/libraries/Datatable.php @@ -213,12 +213,7 @@ public function datatableJson($formats = array(), $debug = FALSE) $colName = $columnIdxArray[$o['column']]; //handle custom sql expressions/subselects if (substr($colName, 0, 2) === '$.') { - $aliasKey = substr($colName, 2); - if (isset($customExpArray[$aliasKey]) === FALSE) { - throw new Exception('Alias[' . $aliasKey . '] Could Not Be Found In appendToSelectStr() Array'); - } - - $colName = $customExpArray[$aliasKey]; + $colName = substr($colName, 2); } $this->CI->db->order_by($colName, $o['dir']); } @@ -457,4 +452,4 @@ public function whereClauseArray(); } // END Datatable Class -/* End of file Datatable.php */ \ No newline at end of file +/* End of file Datatable.php */