mirror of
https://github.com/jonathan-martz/pocketbase-php-sdk.git
synced 2026-04-03 07:27:42 +00:00
add logic for get list
This commit is contained in:
@@ -32,6 +32,20 @@ class Collection
|
|||||||
$this->collection = $collection;
|
$this->collection = $collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $start
|
||||||
|
* @param int $end
|
||||||
|
* @param array $queryParams
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getList(int $start = 1, int $end = 50, array $queryParams = []): array
|
||||||
|
{
|
||||||
|
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
||||||
|
$response = $this->doRequest($this->url . "/api/collections/" . $this->collection . "/records?" . $getParams, 'GET');
|
||||||
|
|
||||||
|
return json_decode($response, JSON_FORCE_OBJECT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $batch
|
* @param int $batch
|
||||||
* @param array $queryParams
|
* @param array $queryParams
|
||||||
@@ -39,6 +53,7 @@ class Collection
|
|||||||
*/
|
*/
|
||||||
public function getFullList(int $batch = 200, array $queryParams = []): array
|
public function getFullList(int $batch = 200, array $queryParams = []): array
|
||||||
{
|
{
|
||||||
|
$queryParams = [... $queryParams, ['perPage' => $batch]];
|
||||||
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
$getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
|
||||||
$response = $this->doRequest($this->url . "/api/collections/" . $this->collection . "/records?" . $getParams, 'GET');
|
$response = $this->doRequest($this->url . "/api/collections/" . $this->collection . "/records?" . $getParams, 'GET');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user