From: nupplaPhil Date: Wed, 22 Jan 2020 19:28:56 +0000 (+0100) Subject: Revert Repo::select()/selectFirst() changes X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=82f37ccdaf73e2f5f7e5b15d4e35cc64c1299b79;p=friendica.git Revert Repo::select()/selectFirst() changes --- diff --git a/src/BaseRepository.php b/src/BaseRepository.php index a66914e88b..c0bcab18f9 100644 --- a/src/BaseRepository.php +++ b/src/BaseRepository.php @@ -63,15 +63,13 @@ abstract class BaseRepository extends BaseFactory * Chainable. * * @param array $condition - * @param array $order An optional array with order information - * @param int|array $limit Optional limit information - * + * @param array $params * @return BaseCollection * @throws \Exception */ - public function select(array $condition = [], array $order = [], $limit = null) + public function select(array $condition = [], array $params = []) { - $models = $this->selectModels($condition, $order, $limit); + $models = $this->selectModels($condition, $params); return new static::$collection_class($models); } @@ -83,15 +81,14 @@ abstract class BaseRepository extends BaseFactory * Chainable. * * @param array $condition - * @param array $order + * @param array $params * @param int? $max_id * @param int? $since_id * @param int $limit - * * @return BaseCollection * @throws \Exception */ - public function selectByBoundaries(array $condition = [], array $order = [], int $max_id = null, int $since_id = null, int $limit = self::LIMIT) + public function selectByBoundaries(array $condition = [], array $params = [], int $max_id = null, int $since_id = null, int $limit = self::LIMIT) { $condition = DBA::collapseCondition($condition); @@ -107,7 +104,9 @@ abstract class BaseRepository extends BaseFactory $boundCondition[] = $since_id; } - $models = $this->selectModels($boundCondition, $order, $limit); + $params['limit'] = $limit; + + $models = $this->selectModels($boundCondition, $params); $totalCount = DBA::count(static::$table_name, $condition); @@ -176,24 +175,12 @@ abstract class BaseRepository extends BaseFactory /** * @param array $condition Query condition - * @param array $order An optional array with order information - * @param int|array $limit Optional limit information - * + * @param array $params Additional query parameters * @return BaseModel[] * @throws \Exception */ - protected function selectModels(array $condition, array $order = [], $limit = null) + protected function selectModels(array $condition, array $params = []) { - $params = []; - - if (!empty($order)) { - $params['order'] = $order; - } - - if (!empty($limit)) { - $params['limit'] = $limit; - } - $result = $this->dba->select(static::$table_name, [], $condition, $params); /** @var BaseModel $prototype */ diff --git a/src/Repository/Introduction.php b/src/Repository/Introduction.php index 4f9806312c..65c2e1ebc7 100644 --- a/src/Repository/Introduction.php +++ b/src/Repository/Introduction.php @@ -35,28 +35,26 @@ class Introduction extends BaseRepository /** * @param array $condition - * @param array $order An optional array with order information - * @param int|array $limit Optional limit information - * + * @param array $params * @return Collection\Introductions * @throws \Exception */ - public function select(array $condition = [], array $order = [], $limit = null) + public function select(array $condition = [], array $params = []) { - return parent::select($condition, $order, $limit); + return parent::select($condition, $params); } /** * @param array $condition - * @param array $order + * @param array $params * @param int|null $max_id * @param int|null $since_id - * @param int|array $limit + * @param int $limit * @return Collection\Introductions * @throws \Exception */ - public function selectByBoundaries(array $condition = [], array $order = [], int $max_id = null, int $since_id = null, int $limit = self::LIMIT) + public function selectByBoundaries(array $condition = [], array $params = [], int $max_id = null, int $since_id = null, int $limit = self::LIMIT) { - return parent::selectByBoundaries($condition, $order, $max_id, $since_id, $limit); + return parent::selectByBoundaries($condition, $params, $max_id, $since_id, $limit); } } diff --git a/src/Repository/PermissionSet.php b/src/Repository/PermissionSet.php index 27c77d6052..7cbee4b836 100644 --- a/src/Repository/PermissionSet.php +++ b/src/Repository/PermissionSet.php @@ -61,29 +61,27 @@ class PermissionSet extends BaseRepository /** * @param array $condition - * @param array $order An optional array with order information - * @param int|array $limit Optional limit information - * + * @param array $params * @return Collection\PermissionSets * @throws \Exception */ - public function select(array $condition = [], array $order = [], $limit = null) + public function select(array $condition = [], array $params = []) { - return parent::select($condition, $order, $limit); + return parent::select($condition, $params); } /** * @param array $condition - * @param array $order + * @param array $params * @param int|null $max_id * @param int|null $since_id - * @param int|array $limit + * @param int $limit * @return Collection\PermissionSets * @throws \Exception */ - public function selectByBoundaries(array $condition = [], array $order = [], int $max_id = null, int $since_id = null, int $limit = self::LIMIT) + public function selectByBoundaries(array $condition = [], array $params = [], int $max_id = null, int $since_id = null, int $limit = self::LIMIT) { - return parent::selectByBoundaries($condition, $order, $max_id, $since_id, $limit); + return parent::selectByBoundaries($condition, $params, $max_id, $since_id, $limit); } /**