public function insert(FoodOrder $foodOrder) { //needs changing //$now = new DateTime(); $foodOrder->setOrderId(null); //$flightBooking->setCreatedOn($now); //$flightBooking->setLastModifiedOn($now); $foodOrder->setStatus(FoodOrder::PENDING); // $sql = 'INSERT INTO food_order (order_id, user_id, full_name, email, phone_number, product_id, status) // VALUES (:order_id, :user_id, :full_name, :email, :phone_number, :product_id, :status)'; $sql = ' INSERT INTO food_orders (order_id, user_id, full_name, phone_number, email, product_id, status) VALUES (:order_id, :user_id, :full_name, :phone_number, :email, :product_id, :status)'; return $this->execute($sql, $foodOrder); }
//pretending to have values in $_POST //$data = array('first_name' => 'Bob', 'no_of_passengers' => 2); //populate with user data $user_id = 1; //get from session // get from DB // $full_name = 'Bob Smith'; //$phone_number = '0278839406'; //$email = '*****@*****.**'; $foodOrder->setUserId($user_id); $foodOrder->setFullName($full_name); $foodOrder->setPhoneNumber($phone_number); $foodOrder->setEmail($email); $foodOrder->setProductId($product_id); //set default status $foodOrder->setStatus('PENDING'); //$foodOrder -> setPickupTime($pickup_time); $foodOrder->setDate(date("Y-m-d H:i:s")); $status = ''; if (isset($_POST['food_order']['status'])) { $status = filter_var($_POST['food_order']['status'], FILTER_SANITIZE_STRING); } else { $status = 'PENDING'; } $data = array('product_id' => $_POST['food_order']['order_list'], 'user_id' => 1, 'full_name' => 'Bob Smith', 'email' => '*****@*****.**', 'phone_number' => '0278839406', 'date' => date("Y-m-d H:i:s"), 'status' => $status); // var_dump($_POST); // die(); // map FoodOrderMapper::map($foodOrder, $data); // validate // $errors = FoodOrderValidator::validate($foodOrder);