Skip to content

Commit

Permalink
Update Datatables.php
Browse files Browse the repository at this point in the history
fixing #134
  • Loading branch information
Kamil Tunkiewicz committed Sep 4, 2014
1 parent 5a779fa commit de6c690
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/Bllim/Datatables/Datatables.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,46 +506,46 @@ protected function filtering()
// global search
if ($this->input['search']['value'] != '')
{
$copy_this = $this;
$_this = $this;

$this->query->where(function($query) use ($copy_this, $columns_copy, $columns_clean) {
$this->query->where(function($query) use (&$_this, $columns_copy, $columns_clean) {

$db_prefix = $copy_this->database_prefix();
$db_prefix = $_this->database_prefix();

for ($i=0,$c=count($this->input['columns']);$i<$c;$i++)
for ($i=0,$c=count($_this->input['columns']);$i<$c;$i++)
{
if (isset($columns_copy[$i]) && $this->input['columns'][$i]['searchable'] == "true")
if (isset($columns_copy[$i]) && $_this->input['columns'][$i]['searchable'] == "true")
{
// if filter column exists for this columns then use user defined method
if (isset($this->filter_columns[$columns_copy[$i]]))
if (isset($_this->filter_columns[$columns_copy[$i]]))
{
// check if "or" equivalent exists for given function
// and if the number of parameters given is not excess
// than call the "or" equivalent

$method_name = 'or' . ucfirst($this->filter_columns[$columns_copy[$i]]['method']);
$method_name = 'or' . ucfirst($_this->filter_columns[$columns_copy[$i]]['method']);

if ( method_exists($query->getQuery(), $method_name) && count($this->filter_columns[$columns_copy[$i]]['parameters']) <= with(new \ReflectionMethod($query->getQuery(),$method_name))->getNumberOfParameters() )
if ( method_exists($query->getQuery(), $method_name) && count($_this->filter_columns[$columns_copy[$i]]['parameters']) <= with(new \ReflectionMethod($query->getQuery(),$method_name))->getNumberOfParameters() )
{
call_user_func_array(
array(
$query,
$method_name
),
$this->inject_variable(
$this->filter_columns[$columns_copy[$i]]['parameters'],
$this->input['search']['value']
$_this->inject_variable(
$_this->filter_columns[$columns_copy[$i]]['parameters'],
$_this->input['search']['value']
)
);
}
} else
// otherwise do simple LIKE search
{

$keyword = '%'.$this->input['search']['value'].'%';
$keyword = '%'.$_this->input['search']['value'].'%';

if(Config::get('datatables::search.use_wildcards', false)) {
$keyword = $copy_this->wildcard_like_string($this->input['search']['value']);
$keyword = $_this->wildcard_like_string($_this->input['search']['value']);
}

// Check if the database driver is PostgreSQL
Expand Down Expand Up @@ -598,7 +598,7 @@ protected function filtering()
$keyword = '%'.$this->input['columns'][$i]['search']['value'].'%';

if(Config::get('datatables::search.use_wildcards', false)) {
$keyword = $copy_this->wildcard_like_string($this->input['columns'][$i]['search']['value']);
$keyword = $this->wildcard_like_string($this->input['columns'][$i]['search']['value']);
}

if(Config::get('datatables::search.case_insensitive', false)) {
Expand Down

0 comments on commit de6c690

Please sign in to comment.