-
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.
When filtering you can not use the alias for WHERE #66 Convert columns as raw if they contain a parenthesis
- Loading branch information
1 parent
aed14a6
commit f68d685
Showing
1 changed file
with
8 additions
and
6 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.1 | ||
* @version 1.3.3 | ||
* @author Bilal Gultekin <[email protected]> | ||
*/ | ||
|
||
|
@@ -345,7 +345,7 @@ private function ordering() | |
|
||
if(!is_null(Input::get('iSortCol_0'))) | ||
{ | ||
$columns = $this->cleanColumns( $this->last_columns ); | ||
$columns = $this->clean_columns( $this->last_columns ); | ||
|
||
for ( $i=0, $c=intval(Input::get('iSortingCols')); $i<$c ; $i++ ) | ||
{ | ||
|
@@ -360,15 +360,16 @@ private function ordering() | |
} | ||
/** | ||
* @param array $cols | ||
* @param bool $use_alias weather to get the column/function or the alias | ||
* @return array | ||
*/ | ||
private function cleanColumns( $cols ) | ||
private function clean_columns( $cols, $use_alias = true) | ||
{ | ||
$return = array(); | ||
foreach ( $cols as $i=> $col ) | ||
{ | ||
preg_match('#^(.*?)\s+as\s+(\S*?)$#si',$col,$matches); | ||
$return[$i] = empty($matches) ? $col : $matches[2]; | ||
$return[$i] = empty($matches) ? $col : $matches[$use_alias?2:1]; | ||
} | ||
|
||
return $return; | ||
|
@@ -382,7 +383,7 @@ private function cleanColumns( $cols ) | |
|
||
private function filtering() | ||
{ | ||
$columns = $this->cleanColumns( $this->columns ); | ||
$columns = $this->clean_columns( $this->columns, false ); | ||
|
||
if (Input::get('sSearch','') != '') | ||
{ | ||
|
@@ -448,7 +449,8 @@ private function filtering() | |
$column = $db_prefix . $columns[$i]; | ||
$this->query->where(DB::raw('LOWER('.$column.')'),'LIKE', $keyword); | ||
} else { | ||
$this->query->where($columns[$i], 'LIKE', $keyword); | ||
$col = strstr($columns[$i],'(')?DB::raw($columns[$i]):$columns[$i]; | ||
$this->query->where($col], 'LIKE', $keyword); | ||
} | ||
} | ||
} | ||
|