/** * Fetches a single order by its unique Id. * * @param int $id * @return Order */ public function getById($id) { try { $result = $this->_database->fetchOne( 'SELECT o.*,c.* FROM order o INNER JOIN customer c ON o.customer_id = c.id WHERE o.id = ?', array($id)); if ($result == null) throw new \Exception("Could not find order with id " . $id); $customer = new Customer(); $customer->setName($result['name']); $customer->setAddress1($result['address_1']); $customer->setAddress2($result['address_2']); $customer->setCity($result['city']); $customer->setState($result['state']); $customer->setPostalCode($result['postal_code']); $customer->setCellphone($result['cell_phone']); $customer->setEmail($result['email']); $customer->setCallbackUrl($result['callback_url']); $order = new Order(); $order->setId($id); $order->setCustomer($customer); return $order; } catch (\Exception $e) { throw $e; } }