The presentation tier passes the ID of the selected category, and you
need to send back the name and the description of the selected category.
// Retrieves complete details for the specified category
public static function GetCategoryDetails($categoryId)
{
// Build SQL query
$sql = 'CALL catalog_get_category_details(:category_id)';
// Build the parameters array
$params = array (':category_id' => $categoryId);
CHAPTER 5 ?– CREATING THE PRODUCT CATALOG: PART 2 140
// Execute the query and return the results
return DatabaseHandler::GetRow($sql, $params);
}
HowManyPages
As you know, our product catalog will display a fixed number of products in every page. When
a catalog page contains more than an established number of products, we display navigation
controls that allow the visitor to browse back and forth through the subpages of products. You
can see the navigation controls in Figure 4-2 in Chapter 4.
When displaying the navigation controls, you need to calculate the number of subpages
of products you have for a given catalog page; for this, we??™re creating the HowManyPages() helper
method.
This method receives as an argument a SELECT query that counts the total number of products
of the catalog page ($countSql) and returns the number of subpages. This will be done by
simply dividing the total number of products by the number of products to be displayed in a
subpage of products; this latter number is configurable through the PRODUCTS_PER_PAGE constant
in include/config.
Pages:
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241