From 8dc4a3cc5995a2a7da7c56d2cfaaae8872bb4e05 Mon Sep 17 00:00:00 2001 From: Leonardo Wong Date: Fri, 28 Feb 2014 18:36:47 +0800 Subject: [PATCH] Update parseQuery.php bug fix, no search query, but need pagination --- parseQuery.php | 71 ++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 40 deletions(-) diff --git a/parseQuery.php b/parseQuery.php index cf4cda7..52acec6 100644 --- a/parseQuery.php +++ b/parseQuery.php @@ -24,53 +24,44 @@ public function __construct($class=''){ } public function find(){ - if(empty($this->_query)){ - $request = $this->request(array( - 'method' => 'GET', - 'requestUrl' => $this->_requestUrl - )); - - return $request; - + $urlParams = array(); + if(!empty($this->_query)){ + $urlParams['where'] = json_encode( $this->_query ); + } + if(!empty($this->_include)){ + $urlParams['include'] = implode(',',$this->_include); + } + if(!empty($this->_order)){ + $urlParams['order'] = implode(',',$this->_order); + } + if(!empty($this->_limit) || $this->_limit == 0){ + $urlParams['limit'] = $this->_limit; + } + if(!empty($this->_skip)){ + $urlParams['skip'] = $this->_skip; + } + if($this->_count == 1){ + $urlParams['count'] = '1'; } - else{ - $urlParams = array( - 'where' => json_encode( $this->_query ) - ); - if(!empty($this->_include)){ - $urlParams['include'] = implode(',',$this->_include); - } - if(!empty($this->_order)){ - $urlParams['order'] = implode(',',$this->_order); - } - if(!empty($this->_limit) || $this->_limit == 0){ - $urlParams['limit'] = $this->_limit; - } - if(!empty($this->_skip)){ - $urlParams['skip'] = $this->_skip; - } - if($this->_count == 1){ - $urlParams['count'] = '1'; - } - $request = $this->request(array( - 'method' => 'GET', - 'requestUrl' => $this->_requestUrl, - 'urlParams' => $urlParams, - )); + $request = $this->request(array( + 'method' => 'GET', + 'requestUrl' => $this->_requestUrl, + 'urlParams' => $urlParams, + )); - return $request; - } + return $request; + } //setting this to 1 by default since you'd typically only call this function if you were wanting to turn it on - public function setCount($bool=1){ - if(is_bool($bool)){ - $this->_count = $bool; - } + public function setCount($bool=1){ + if(is_bool($bool)){ + $this->_count = $bool; + } else{ - $this->throwError('setCount requires a boolean paremeter'); + $this->throwError('setCount requires a boolean paremeter'); } - } + } public function getCount(){ $this->_count = 1;