Prev | Current Page 214 | Next

Emilian Balanescu and Cristian Darie

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

This is called self-documenting or self-describing code and is
a good habit to form when coding; it will help you??”or anyone else who needs to work on your
site??”to quickly understand what each of your stored procedures does without having to look
inside them. Many a programmer has learned the hard way that two weeks from now you will
not remember what a particular function does, and naming it function_one tells you absolutely
nothing about its purpose; following a self-documenting style will, in the long run, save hours
during debugging and redesign.
In the following sections, you??™ll be shown the code of each stored procedure. We won??™t go
though individual exercises to create these stored procedures. Use phpMyAdmin to add them
to your database, using the SQL tab and changing the DELIMITER to $$, as shown in Figure 5-7.
Figure 5-7. Changing the SQL delimiter in phpMyAdmin
CHAPTER 5 ?–  CREATING THE PRODUCT CATALOG: PART 2 130
?– Caution Don??™t forget to set the delimiter when you create eachstored procedure!
catalog_get_department_details
The catalog_get_department_details stored procedure returns the name and description for
a given department whose ID is received as parameter. This is needed when the user selects a
department in the product catalog, and the database must be queried to find out the name
and the description of the particular department.


Pages:
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226