diff options
author | Camil Staps | 2016-08-01 14:03:44 +0200 |
---|---|---|
committer | Camil Staps | 2016-08-01 14:03:44 +0200 |
commit | 4394857949ce8004fbf81c819f1e774cadad9b3f (patch) | |
tree | c8450147fd727d48177f85f4e712042b06e7df01 /classes/Client.php | |
parent | Makefile dependencies (diff) |
Use Model::search in child::get* methods
Diffstat (limited to 'classes/Client.php')
-rw-r--r-- | classes/Client.php | 14 |
1 files changed, 2 insertions, 12 deletions
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]); } //------------------------------------------------------------------------------ |