From 0402fc3020ca4fb67b136ebabe006a4cd3a47d5a Mon Sep 17 00:00:00 2001 From: jamiechapman Date: Sun, 30 Nov 2014 15:54:02 +0000 Subject: [PATCH 1/3] Fixed bug in find() method If you issue a query without any operands but have orderBy statements, the find() query does not include the "orderBy" fields. This is useful where you want to list *all* objects within class and order by title. --- parseQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parseQuery.php b/parseQuery.php index cf4cda7..1a5988d 100644 --- a/parseQuery.php +++ b/parseQuery.php @@ -24,7 +24,7 @@ public function __construct($class=''){ } public function find(){ - if(empty($this->_query)){ + if(empty($this->_query) && !empty($this->_order)) { $request = $this->request(array( 'method' => 'GET', 'requestUrl' => $this->_requestUrl From c54015c8e0462f35b64a59d6517125bc671547ba Mon Sep 17 00:00:00 2001 From: jamiechapman Date: Sun, 30 Nov 2014 15:58:58 +0000 Subject: [PATCH 2/3] Fixed issue where orderBy fails for queries without operands --- parseQuery.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/parseQuery.php b/parseQuery.php index 1a5988d..6e62b78 100644 --- a/parseQuery.php +++ b/parseQuery.php @@ -24,7 +24,8 @@ public function __construct($class=''){ } public function find(){ - if(empty($this->_query) && !empty($this->_order)) { + if(empty($this->_query) && count($this->_order) === 0) { + $request = $this->request(array( 'method' => 'GET', 'requestUrl' => $this->_requestUrl @@ -37,6 +38,12 @@ public function find(){ $urlParams = array( 'where' => json_encode( $this->_query ) ); + + // Remove where clause if it is not required + if(empty($this->_query)) { + $urlParams = array(); + } + if(!empty($this->_include)){ $urlParams['include'] = implode(',',$this->_include); } @@ -53,6 +60,8 @@ public function find(){ $urlParams['count'] = '1'; } + print_r($urlParams); + $request = $this->request(array( 'method' => 'GET', 'requestUrl' => $this->_requestUrl, From 42d2f70b07168ec4760ea8b173cd8642c2228687 Mon Sep 17 00:00:00 2001 From: jamiechapman Date: Sun, 30 Nov 2014 15:59:32 +0000 Subject: [PATCH 3/3] Update parseQuery.php --- parseQuery.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/parseQuery.php b/parseQuery.php index 6e62b78..b9165a5 100644 --- a/parseQuery.php +++ b/parseQuery.php @@ -60,8 +60,6 @@ public function find(){ $urlParams['count'] = '1'; } - print_r($urlParams); - $request = $this->request(array( 'method' => 'GET', 'requestUrl' => $this->_requestUrl,