public static function setOrder(Order $order) { $query = "INSERT INTO commandes (prix, id_user)\n\t\t\tVALUES ('" . $order->getPrice() . "','" . $order->getIdUser() . "')"; DBOperation::exec($query); $lastId = DBOperation::getLastId(); foreach ($_SESSION["cart"] as $product) { $query = "INSERT INTO produits_commandes (id_produit, id_commande, quantity)\n\t\t\t\tVALUES ('" . $product->getId() . "','" . $lastId . "','" . $product->getQuantity() . "')"; DBOperation::exec($query); } }
private static function convertToObject($aOrder) { $oOrder = new Order(); $oOrder->setId($aOrder['id']); $oOrder->setEmail($aOrder['user_email']); $oOrder->setDate($aOrder['date']); $oOrder->setTotal($aOrder['total']); return $oOrder; }