In the second e-commerce example in my “Effortless E-Commerce with PHP and MySQL” book, stored procedures were used for all of the public-side database-related functionality. This includes: the displaying of product categories, specific items, and sale items; cart and wish list management (adding items, updating quantities, removing items); and order submissions. As I write in the book, stored procedures offer tons of benefits, the most critical being:
- Greatly improved security
- Better performance
- Compartmentalization of code (i.e., adherence to an MVC approach)
However, not everyone can use stored procedures, in particular those on some shared hosting environments. One reader recently said (in the forums) that they couldn’t use stored procedures with their host, so I volunteered to rewrite some of the stored procedures as standard PHP and MySQL. In this post, I’ll rewrite the procedures, and corresponding PHP scripts, from Chapter 8, “Creating a Catalog”. Continue Reading…