php:
CHAPTER 18 ?– IMPLEMENTING THE ORDER PIPELINE: PART 1 587
// Set order's authorization code and reference code
public function SetAuthCodeAndReference($authCode, $reference)
{
Orders::SetOrderAuthCodeAndReference($this->mOrderInfo['order_id'],
$authCode, $reference);
$this->mOrderInfo['auth_code'] = $authCode;
$this->mOrderInfo['reference'] = $reference;
}
This code also sets the corresponding elements from the $mOrderInfo array, just in case they
are required before the OrderProcessor terminates. In this situation, it wouldn??™t make much
sense to get these values from the database when we already know what the result will be.
In the next chapter, when we deal with credit card usage, we??™ll need to set data in the
auth_code and reference fields in the orders table.
Exercise: Setting the Order Shipment Date
1. When an order is shipped, we should update the shipment date in the database, which can simply be the
current date. Add the orders_set_date_shipped stored procedure to the tshirtshop database:
-- Create orders_set_date_shipped stored procedure
CREATE PROCEDURE orders_set_date_shipped(IN inOrderId INT)
BEGIN
UPDATE orders SET shipped_on = NOW() WHERE order_id = inOrderId;
END$$
2. Add the new data tier method, SetDateShipped(), to the Orders class in business/orders.php as
follows:
// Set order's ship date
public static function SetDateShipped($orderId)
{
// Build the SQL query
$sql = 'CALL orders_set_date_shipped(:order_id)';
// Build the parameters array
$params = array (':order_id' => $orderId);
// Execute the query
DatabaseHandler::Execute($sql, $params);
}
CHAPTER 18 ?– IMPLEMENTING THE ORDER PIPELINE: PART 1 588
3.
Pages:
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707