Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions libraries/Datatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class Datatable

private $protectIdentifiers = FALSE;

/** Array $filter_array */
private $filter_array;


/**
* @params
Expand All @@ -63,6 +66,8 @@ public function __construct($params)

$model = $params['model'];

$this->filter_array = isset($params['filter']) ? $params['filter'] : NULL;

$this->rowIdCol = isset($params['rowIdCol']) ? $params['rowIdCol'] : NULL;

$CI->load->model($model);
Expand Down Expand Up @@ -415,6 +420,14 @@ private function sqlJoinsAndWhere()

//append a static where clause to what the user has filtered, if the model tells us to do so
$wArray = $this->model->whereClauseArray();

//When loading model, can also define filter as a param
if($this->filter_array !== NULL){
foreach ($this->filter_array as $key=>$filter){
$wArray[$key] = $filter;
}
}

if (is_null($wArray) === FALSE && is_array($wArray) === TRUE && count($wArray) > 0) {
$this->CI->db->where($wArray, $this->protectIdentifiers);
}
Expand Down