-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CleanCollumns function more flexible
get the alias of a column regardless of function name
- Loading branch information
1 parent
255f016
commit aed14a6
Showing
1 changed file
with
19 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* | ||
* @package Laravel | ||
* @category Bundle | ||
* @version 1.3 | ||
* @version 1.3.1 | ||
* @author Bilal Gultekin <[email protected]> | ||
*/ | ||
|
||
|
@@ -23,21 +23,22 @@ class Datatables | |
public $query; | ||
protected $query_type; | ||
|
||
protected $extra_columns = array(); | ||
protected $excess_columns = array(); | ||
protected $edit_columns = array(); | ||
protected $sColumns = array(); | ||
protected $extra_columns = array(); | ||
protected $excess_columns = array(); | ||
protected $edit_columns = array(); | ||
protected $sColumns = array(); | ||
|
||
public $columns = array(); | ||
public $columns = array(); | ||
public $last_columns = array(); | ||
|
||
protected $count_all = 0; | ||
protected $display_all = 0; | ||
|
||
protected $result_object; | ||
protected $result_array = array(); | ||
protected $result_array = array(); | ||
protected $result_array_r = array(); | ||
|
||
protected $mDataSupport; | ||
protected $mDataSupport; | ||
|
||
|
||
/** | ||
|
@@ -357,33 +358,20 @@ private function ordering() | |
|
||
} | ||
} | ||
|
||
/** | ||
* @param array $cols | ||
* @return array | ||
*/ | ||
private function cleanColumns( $cols ) | ||
{ | ||
$_search = [ | ||
'GROUP_CONCAT( ', | ||
'CONCAT( ', | ||
'DISTINCT( ', | ||
',', | ||
' )', | ||
'as', | ||
]; | ||
|
||
foreach ( $cols as $col ) | ||
$return = array(); | ||
foreach ( $cols as $i=> $col ) | ||
{ | ||
$_column = explode( ' ' , str_replace( $_search, '', $col, $count ) ); | ||
|
||
if ( $count > 0 ) | ||
{ | ||
$columns[] = array_shift( $_column ); | ||
} | ||
else | ||
{ | ||
$columns[] = end( $_column ); | ||
} | ||
preg_match('#^(.*?)\s+as\s+(\S*?)$#si',$col,$matches); | ||
$return[$i] = empty($matches) ? $col : $matches[2]; | ||
} | ||
|
||
return $columns; | ||
return $return; | ||
} | ||
|
||
/** | ||
|
@@ -411,9 +399,7 @@ private function filtering() | |
{ | ||
if (Input::get('bSearchable_'.$i) == "true") | ||
{ | ||
|
||
preg_match('#^(.*?)\s+as\s+(\S*?)$#si',$copy_this->columns[$i],$matches); | ||
$column = empty($matches) ? $copy_this->columns[$i] : $matches[1]; | ||
$column = $copy_this->columns[$i]; | ||
|
||
if (stripos($column, ' AS ') !== false){ | ||
$column = substr($column, stripos($column, ' AS ')+4); | ||
|