Prev | Current Page 228 | Next

Emilian Balanescu and Cristian Darie

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


CHAPTER 5 ?–  CREATING THE PRODUCT CATALOG: PART 2 139
The needed data is obtained by calling the catalog_get_department_details stored
procedure that you??™ve written earlier. Just as planned, the business tier acts, in this case,
as a buffer between the presentation tier and the data tier.
// Retrieves complete details for the specified department
public static function GetDepartmentDetails($departmentId)
{
// Build SQL query
$sql = 'CALL catalog_get_department_details(:department_id)';
// Build the parameters array
$params = array (':department_id' => $departmentId);
// Execute the query and return the results
return DatabaseHandler::GetRow($sql, $params);
}
GetCategoriesInDepartment
The GetCategoriesInDepartment() method is called to retrieve the list of categories that
belong to a department. Add this method to the Catalog class:
// Retrieves list of categories that belong to a department
public static function GetCategoriesInDepartment($departmentId)
{
// Build SQL query
$sql = 'CALL catalog_get_categories_list(:department_id)';
// Build the parameters array
$params = array (':department_id' => $departmentId);
// Execute the query and return the results
return DatabaseHandler::GetAll($sql, $params);
}
GetCategoryDetails
GetCategoryDetails() is called from the presentation tier when a category is clicked to display
its name and description.


Pages:
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240