Page 477 - Beginning PHP 5.3
P. 477

Chapter 14: Manipulating MySQL Data with PHP
                            ❑       You also created a members ’  area of the book club site, where members can log in, log out, and
                                view pages. This involved enhancing your   Member  class with an  authenticate()  method to
                                check login details, adding a   record()  method to the  LogEntry  class to track page views, and
                                adding a   checkLogin()  function to your common code to check that a member is logged in.
                                Then you created a login script to display and handle the login form, a logout script to log the
                                member out, and various sample pages within the members ’  area.
                            ❑       In the last part of the chapter, you extended your   view_member.php  script from the previous
                                chapter to allow the administrator to edit a member ’ s details, as well as delete members from
                                the   members  table. Along the way, you added  update()  and  delete()  methods to your
                                  Member  class, and wrote a  LogEntry  class method to delete all log entries for a particular
                                member.
                            Now that you ’ ve worked your way through these three chapters, you have the basic knowledge needed
                          to build rich, database - driven PHP applications. Although these chapters have covered the basics, there ’ s
                          a lot more to both MySQL and PDO than has been explored here. If you want to find out more, check out
                          the online MySQL manual at   http://dev.mysql.com/doc/#manual  and the PDO section of the PHP
                         manual at   http://www.php.net/pdo . Have fun!
                            In the next chapter you move onto a new topic: PEAR. This is a huge library of free, ready - made PHP
                          scripts that can really help to speed up your application development process. Before you move on,
                          though, take a look at the following  two exercises to cement your knowledge of SQL and database -
                            driven applications. You can find the solutions to these exercises in Appendix A.



                           Exercises
                               1.       Write an SQL query that returns a list of favorite genres in the book club ’ s  members  table
                                ordered by popularity, most popular first.
                               2.       Add a Clear Access Log button to your member editor script,  view_member.php , that deletes all
                                records in the   accessLog  table pertaining to the member being viewed.



























                                                                                                         439





                                                                                                      9/21/09   9:14:16 AM
          c14.indd   439
          c14.indd   439                                                                              9/21/09   9:14:16 AM
   472   473   474   475   476   477   478   479   480   481   482