Prev | Current Page 579 | Next

Emilian Balanescu and Cristian Darie

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

html. If newer versions of
MySQL fix these problems, when performance becomes an issue, you could take into consideration making tests
using the rewritten versions of these stored procedures. In some cases, the versions that use subqueries offer better
performance.
Implementing Product and Shopping Cart
Recommendations
In the following exercise, you??™ll write the code for the business and presentation tiers of the
product recommendation system.
The business tier of the product recommendation system consists of two methods both
named GetRecommendations. One of them is located in the Catalog class and retrieves recommendations
for a product details page, and the other one is located in the ShoppingCart class
and retrieves recommendations to be displayed in the visitor??™s shopping cart.
Exercise: Implementing Product and Shopping Cart Recommendations
1. Add the following method to the Catalog class in business/catalog.php file:
// Get product recommendations
public static function GetRecommendations($productId)
{
// Build the SQL query
$sql = 'CALL catalog_get_recommendations(
:product_id, :short_product_description_length)';
// Build the parameters array
$params = array (':product_id' => $productId,
':short_product_description_length' =>
SHORT_PRODUCT_DESCRIPTION_LENGTH);
CHAPTER 15 ?–  PRODUCT RECOMMENDATIONS 470
// Execute the query and return the results
return DatabaseHandler::GetAll($sql, $params);
}
2.


Pages:
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591
e-lady traktorki ogrodowe need cash fast bad credit prace wysokościowe Program TV