diff options
Diffstat (limited to 'codebase')
-rw-r--r-- | codebase/base_connector.php | 14 | ||||
-rw-r--r-- | codebase/db_common.php | 9 |
2 files changed, 20 insertions, 3 deletions
diff --git a/codebase/base_connector.php b/codebase/base_connector.php index 8cf3625..9f0bb85 100644 --- a/codebase/base_connector.php +++ b/codebase/base_connector.php @@ -302,6 +302,7 @@ class Connector { protected $extra_output="";//!< extra info which need to be sent to client side protected $options=array();//!< hash of OptionsConnector protected $as_string = false; + protected $filters; /*! constructor @@ -331,6 +332,7 @@ class Connector { "render_class"=>$render_type ); $this->attributes = array(); + $this->filters = array(); $this->config = new DataConfig(); $this->request = new DataRequestConfig(); @@ -482,6 +484,7 @@ class Connector { $wrap->store(); $wrap = new FilterInterface($this->request); + $this->apply_filters($wrap); $this->event->trigger("beforeFilter",$wrap); $wrap->store(); @@ -797,6 +800,17 @@ class Connector { public function asString($as_string) { $this->as_string = $as_string; } + + public function filter($name, $value = false, $operation = '=') { + $this->filters[] = array('name' => $name, 'value' => $value, 'operation' => $operation); + } + + protected function apply_filters($wrap) { + for ($i = 0; $i < count($this->filters); $i++) { + $f = $this->filters[$i]; + $wrap->add($f['name'], $f['value'], $f['operation']); + } + } } diff --git a/codebase/db_common.php b/codebase/db_common.php index 8b5935a..91d3838 100644 --- a/codebase/db_common.php +++ b/codebase/db_common.php @@ -170,8 +170,11 @@ class DataRequestConfig{ @param operation operation for filtering, optional , LIKE by default */ - public function set_filter($field,$value,$operation=false){ - array_push($this->filters,array("name"=>$field,"value"=>$value,"operation"=>$operation)); + public function set_filter($field,$value=false,$operation=false){ + if ($value === false) + array_push($this->filters,$field); + else + array_push($this->filters,array("name"=>$field,"value"=>$value,"operation"=>$operation)); } /*! sets list of used fields @@ -672,7 +675,7 @@ abstract class DBDataWrapper extends DataWrapper{ public function sequence($sec){ $this->sequence=$sec; } - + /*! create an sql string for filtering rules |