From 51c2943f493a48aacbeefca50f5c9f5d757f658f Mon Sep 17 00:00:00 2001 From: jcheron Date: Sat, 23 Apr 2022 19:43:43 +0200 Subject: [PATCH] [skip ci]{orm] add count to AbstractRepo --- CHANGELOG.md | 3 ++- .../orm/repositories/AbstractRepository.php | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1e53ca7b..0ec87e520 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Nothing -## [2.4.12] 2022-04-20 +## [2.4.12] 2022-04-24 ### Added +- `count` method to `AbstractRepository` - app methods to Logger: `appLog`, `appInfo`, `appError`... - regenerateId for `USession` - `DataFormHelper` class for model form generation diff --git a/src/Ubiquity/orm/repositories/AbstractRepository.php b/src/Ubiquity/orm/repositories/AbstractRepository.php index 9030d782f..5cc51d654 100644 --- a/src/Ubiquity/orm/repositories/AbstractRepository.php +++ b/src/Ubiquity/orm/repositories/AbstractRepository.php @@ -12,7 +12,7 @@ * This class is part of Ubiquity * * @author jc - * @version 1.0.1 + * @version 1.0.2 * */ abstract class AbstractRepository { @@ -101,4 +101,15 @@ public function save(object $instance, $insertMany = false) { public function remove(object $instance): ?int { return DAO::remove ( $instance ); } + + /** + * Returns the number of instances. + * + * @param string $condition + * @param array $parameters + * @return int + */ + public function count(string $condition='',?array $parameters=null):int { + return DAO::count($this->getModel(),$condition,$parameters); + } }