getTable($this->tableAlias . 'Address')->saveRelations($addresses, $key); } public function getContactAddress(array $key) { $key['type'] = Entity::TYPE_CONCACT; return $this->getAddress($key); } public function getBillingAddress(array $key) { $key['type'] = Entity::TYPE_BILLING; return $this->getAddress($key); } public function getShippingAddress(array $key) { $key['type'] = Entity::TYPE_SHIPPING; return $this->getAddress($key); } public function getMailingAddress(array $key) { $key['type'] = Entity::TYPE_MAILING; return $this->getAddress($key); } private function getAddress(array $key) { $select = $this->db->select(); $columns = ['address', 'address2', 'city', 'state', 'zip']; if ($key['type'] == Entity::TYPE_BILLING) { $columns = array_merge(['firstName', 'lastName'], $columns); } $select->from(Qs_Db::getPair($this->tableAlias . 'Address', 'a'), $columns); $select->join(Qs_Db::getPair('DState', 's'), '`s`.`id` = `a`.`state`', ['stateName' => 'title']); Qs_Db::filter($select, $key, 'a', Qs_Db::FILTER_THROW_UNKNOWN); return $this->db->fetchRow($select); } }