/** * Get all the contact emails * @param $customer_id * @return ArrayObject */ public static function getEmails($customer_id) { $emails = array(); if (is_numeric($customer_id)) { $mainmail = Customers::getEmailAddress($customer_id); if (!empty($mainmail)) { $emails[] = $mainmail; } $records = Doctrine_Query::create()->select('contact_id, contact as email')->from('Contacts c')->leftJoin('c.ContactsTypes t')->where("customer_id = ? and t.name = ?", array($customer_id, "email"))->execute(array(), Doctrine_Core::HYDRATE_ARRAY); foreach ($records as $record) { $emails[] = $record['email']; } return !empty($emails) ? $emails : NULL; } }