??? All links in your web site use the dynamic versions of the URLs.
With these two drawbacks, the mere fact that we do support keyword-rich URLs doesn??™t
bring any significant benefits. This leads us to a second exercise related to our URLs. This
time, we??™ll change the dynamic links in our site to keyword-rich URLs.
In the earlier chapters, we??™ve been wise enough to use a centralized class named Link that
generates all of the site??™s links. This means that, now, updating all the links in our site is just
a matter of updating that Link class. We??™ll also need to build some data tier and business tier
infrastructure to support the new functionality, which consists of methods that return the
name of a department, category, or product if we supply the ID.
Exercise: Generating Keyword-Rich URLs
1. Use phpMyAdmin to connect to your tshirtshop database, and execute the following code, which creates
three stored procedures. These are simple procedures that return the name of a department, a category, or
a product given its ID. Don??™t forget to set $$ as the delimiter before executing the code.
-- Create catalog_get_department_name stored procedure
CREATE PROCEDURE catalog_get_department_name(IN inDepartmentId INT)
BEGIN
SELECT name FROM department WHERE department_id = inDepartmentId;
END$$
-- Create catalog_get_category_name stored procedure
CREATE PROCEDURE catalog_get_category_name(IN inCategoryId INT)
BEGIN
SELECT name FROM category WHERE category_id = inCategoryId;
END$$
-- Create catalog_get_product_name stored procedure
CREATE PROCEDURE catalog_get_product_name(IN inProductId INT)
BEGIN
SELECT name FROM product WHERE product_id = inProductId;
END$$
2.
Pages:
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310