Prev | Current Page 554 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

Execute this code, which creates the orders_get_orders_by_status stored procedure. This procedure
returns the orders that have the status value specified by the inStatus parameter.
-- Create orders_get_orders_by_status stored procedure
CREATE PROCEDURE orders_get_orders_by_status(IN inStatus INT)
CHAPTER 14 ?–  ACCEPTING CUSTOMER ORDERS 447
BEGIN
SELECT order_id, total_amount, created_on,
shipped_on, status, customer_name
FROM orders
WHERE status = inStatus
ORDER BY created_on DESC;
END$$
5. The business tier consists of a new class named Orders, whose methods call their data tier counterparts.
This class is pretty straightforward with no particularly complex logic, so we??™ll just list the code. Create the
business/orders.php file, and add the following code to it:
// Business tier class for the orders
class Orders
{
public static $mOrderStatusOptions = array ('placed', // 0
'verified', // 1
'completed', // 2
'canceled'); // 3
// Get the most recent $how_many orders
public static function GetMostRecentOrders($how_many)
{
// Build the SQL query
$sql = 'CALL orders_get_most_recent_orders(:how_many)';
// Build the parameters array
$params = array (':how_many' => $how_many);
// Execute the query and return the results
return DatabaseHandler::GetAll($sql, $params);
}
// Get orders between two dates
public static function GetOrdersBetweenDates($startDate, $endDate)
{
// Build the SQL query
$sql = 'CALL orders_get_orders_between_dates(:start_date, :end_date)';
// Build the parameters array
$params = array (':start_date' => $startDate, ':end_date' => $endDate);
// Execute the query and return the results
return DatabaseHandler::GetAll($sql, $params);
}
// Gets orders by status
CHAPTER 14 ?–  ACCEPTING CUSTOMER ORDERS 448
public static function GetOrdersByStatus($status)
{
// Build the SQL query
$sql = 'CALL orders_get_orders_by_status(:status)';
// Build the parameters array
$params = array (':status' => $status);
// Execute the query and return the results
return DatabaseHandler::GetAll($sql, $params);
}
}
?>
6.


Pages:
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566
drukarki fiskalne kraków willa karmazyn międzyzdroje www.books61.hobbitstory.com terapia magnetyczna Informacje o hostingu