From 2eae1c56ee845913dc2327d81f8e89fbe405c231 Mon Sep 17 00:00:00 2001 From: mkay-development <110632598+mkay-development@users.noreply.github.com> Date: Sun, 19 Feb 2023 11:28:17 +0100 Subject: [PATCH 1/3] add composer require command --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 93ef16a..09704c4 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ ##### This Repository are in active Development *** +``` bash +composer require mkay-development/pocketbase-php-sdk +``` + ``` php // Example init and use use \Pb\Client as pb; @@ -35,4 +39,4 @@ $pb->collection(collectionIdOrName)->update(string $recordId, array $bodyParams // Deletes a single record by its id. $pb->collection(collectionIdOrName)->delete(string $recordId, array $queryParams = []); -``` \ No newline at end of file +``` From b06f49d219563d4bf64b2cae1a80cd585903b0d9 Mon Sep 17 00:00:00 2001 From: BOCKTAELS Hugo Date: Wed, 22 Feb 2023 09:36:30 +0100 Subject: [PATCH 2/3] Update Client.php collection function (#1) The collection function had 2 parameters (url and page) that were unused and useless. --- src/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index b97e438..e601786 100644 --- a/src/Client.php +++ b/src/Client.php @@ -23,7 +23,7 @@ class Client return new UsersCollection($this->url, 'records'); } - public function collection($url,string $collection, int $page = 1) + public function collection(string $collection) { return new Collection($this->url ,$collection); } From b0b6fbaaa1098e1d189e14cf1034774d488f5f49 Mon Sep 17 00:00:00 2001 From: BOCKTAELS Hugo Date: Wed, 22 Feb 2023 10:55:46 +0100 Subject: [PATCH 3/3] Adding queryParams in curl call using http_build_query() we can simply pass the parameters describe in the Api doc. ex : $this->pb->collection('coolCollection')->getFullList(200,['filter'=> $filter]) It can be used for all other function. --- src/Collection.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Collection.php b/src/Collection.php index bee1dda..c09afe9 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -40,7 +40,8 @@ class Collection public function getFullList(int $batch = 200, array $queryParams = []) { $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $this->url . "/api/collections/" . $this->collection . "/records"); + $getParams = !empty($queryParams) ? http_build_query($queryParams) : ""; + curl_setopt($ch, CURLOPT_URL, $this->url . "/api/collections/" . $this->collection . "/records?".$getParams); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if (self::$token != '') { $headers = array(