From 4394857949ce8004fbf81c819f1e774cadad9b3f Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 1 Aug 2016 14:03:44 +0200 Subject: Use Model::search in child::get* methods --- classes/Client.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'classes/Client.php') diff --git a/classes/Client.php b/classes/Client.php index acae192..0f0a2f8 100644 --- a/classes/Client.php +++ b/classes/Client.php @@ -40,12 +40,7 @@ class Client extends Model { * @return int[] The ids */ public function getContactIds() { - $ids = array(); - $contacts = $this->pdo->query("SELECT `id` FROM `".Constants::db_prefix."contact` WHERE `clientId`={$this->id}")->fetchAll(PDO::FETCH_ASSOC); - foreach ($contacts as $contact) { - $ids[] = $contact['id']; - } - return $ids; + return Contact::searchIds($this->pdo, ['`clientId`=?'], [$this->id]); } /** @@ -58,12 +53,7 @@ class Client extends Model { * @return contact[] An array indexed by id of instances of the contact class */ public function getContacts() { - $ids = $this->getContactIds(); - $contacts = array(); - foreach ($ids as $id) { - $contacts[$id] = new Contact($this->pdo, $id); - } - return $contacts; + return Contact::search($this->pdo, ['`clientId`=?'], [$this->id]); } //------------------------------------------------------------------------------ -- cgit v1.2.3