Each pipeline section
needs the capability to change the status of an order, advancing it to the next pipeline section.
Rather than simply incrementing the status, this functionality is kept flexible, just in case we end
up with amore complicated branched pipeline. This requires a new stored procedure in the database,
named orders_update_status, and a business tier method, UpdateOrderStatus(), which we
need to add to the Orders class (located in business/orders.php).
Exercise: Updating the Status of an Order
1. Start by creating the orders_update_status stored procedure in the tshirtshop database:
-- Create orders_update_status stored procedure
CREATE PROCEDURE orders_update_status(IN inOrderId INT, IN inStatus INT)
BEGIN
UPDATE orders SET status = inStatus WHERE order_id = inOrderId;
END$$
2. Add the UpdateOrderStatus() method to the Orders class in business/orders.php:
// Updates the order pipeline status of an order
public static function UpdateOrderStatus($orderId, $status)
{
// Build the SQL query
$sql = 'CALL orders_update_status(:order_id, :status)';
// Build the parameters array
$params = array (':order_id' => $orderId, ':status' => $status);
CHAPTER 18 ?– IMPLEMENTING THE ORDER PIPELINE: PART 1 586
// Execute the query
DatabaseHandler::Execute($sql, $params);
}
3. The method in OrderProcessor (in business/order_processor.
Pages:
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705