Building a Data Access Class using the PHP PDO Functions
I recently purchased the PHP Cookbook 2ed, which is by far the best PHP book for the novice user. One of the areas in PHP that I haven’t spent much time on is Database Access like getting rows from a table and binding them to an array or inserting a row and getting the new Primary key. Instead of really learning any of that I usually end up using what ever bits of code I find on the web and call it good. I have tried to read the Chapter on Databases in Programming PHP but I just can’t get into reading about database access theory and what not anymore. (I have no excuse but laziness.) Anyhow a few weeks back I was staring a new project and I need to access the database and of course the first thing I did was start digging around for some code examples I had downloaded and grab the data access code. Then I ran into a snag and decide to not be lazy so I cracked the Cookbook open to the Database section. After looking at the code examples a bit I noticed they were looking the other MySQL bits of code I’ve seen. So I flip to the beginning of the chapter and I start reading. It was the usual bla bla bla PDO bla. PDO? Oh Great. More stuff I have neglected to learn.
Read more of this article »
