From 71546705f8a0e301711da8f2730d833bd67404ed Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 27 Apr 2019 22:21:02 -0400 Subject: [PATCH] Add Model\Contact::select method --- src/Model/Contact.php | 14 ++++++++++++++ src/Module/Admin/Blocklist/Contact.php | 4 +--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 85d1bfe9ad..beb91d11a0 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -110,6 +110,20 @@ class Contact extends BaseObject * @} */ + /** + * @param array $fields Array of selected fields, empty for all + * @param array $condition Array of fields for condition + * @param array $params Array of several parameters + * @return array + * @throws \Exception + */ + public static function select(array $fields = [], array $condition = [], array $params = []) + { + $statement = DBA::select('contact', $fields, $condition, $params); + + return DBA::toArray($statement); + } + /** * @param integer $id * @return array|boolean Contact record if it exists, false otherwise diff --git a/src/Module/Admin/Blocklist/Contact.php b/src/Module/Admin/Blocklist/Contact.php index bebcf444b4..214a30cff7 100644 --- a/src/Module/Admin/Blocklist/Contact.php +++ b/src/Module/Admin/Blocklist/Contact.php @@ -52,9 +52,7 @@ class Contact extends BaseAdminModule $pager = new Pager($a->query_string, 30); - $statement = DBA::select('contact', [], $condition, ['limit' => [$pager->getStart(), $pager->getItemsPerPage()]]); - - $contacts = DBA::toArray($statement); + $contacts = Model\Contact::select([], $condition, ['limit' => [$pager->getStart(), $pager->getItemsPerPage()]]); $t = Renderer::getMarkupTemplate('admin/blocklist/contact.tpl'); $o = Renderer::replaceMacros($t, [