phpmysql5-cover.jpg

At parties, one of the things I tell people I do for a living is write books that teach people how to build websites. It might be more accurate, however, to say I write a book: I’ve just written it five times! There’s a special place it my heart for collaborations like Simply JavaScript and Everything You Know About CSS Is Wrong!, but PHP & MySQL: Novice to Ninja (titled “Build Your Own Database Driven Website Using PHP & MySQL” in previous editions) will always be the one I made all by myself.

Approaching the 5th edition was honestly a little daunting; PHP and MySQL haven’t changed much in the three years since I wrote the 4th edition. Of course, the programming language that powers sites like Facebook hasn’t sat stagnant in that time. There are plenty of new frameworks, open source libraries, and development tools to keep an experienced PHP developer occupied, but the basics—the things you learn in a beginner’s book—haven’t changed much at all.

I had a mental of list things that needed to change—some pretty great ideas, actually. So great were they in fact, that when I sat down to start writing I discovered to my dismay that they were all the ideas I’d put into the 4th edition! No wonder I’d liked them so much.

For the first time in all my years writing and re-writing PHP & MySQL: Novice to Ninja, I found myself with the time to improve the book, and no obvious list of things that needed fixing. Apart from some minor updates to the installation instructions, there was nothing actually wrong with the 4th edition. But I’m not the kind of guy (and SitePoint isn’t the kind of publisher) to just bump all the version numbers, stamp a new edition number on the cover, and send it out the door.

What else could I do? I set about making the book even better. With each chapter, I took a step back and thought through the assumptions I’d made about what a beginner learning PHP and MySQL for the first time could do, and then I found a way to do more.

To give just one example, perhaps the core skill that you learn when reading the book is writing PHP code to display content stored in a MySQL database on a web page. PHP supports several ways of doing this, but the best way is to use PHP Data Objects (PDO), a new feature added in PHP 5.0. The thing is, to use PDO you need to understand the basics of object oriented programming, something that I’d always considered too complicated to cover in a beginner’s book; instead, I taught a simpler, more old-fashioned technique.

Instead of sidestepping this challenge, PHP & MySQL: Novice to Ninja, 5th Edition tackles it head on. It teaches the essential concepts of object oriented programming (not to mention exception handling!), then uses PDO like a grownup.

And that might be the best way to summarise the changes in this edition. Just as PHP and MySQL have grown from the young upstarts of the web development world into mature, stable platforms for billion-dollar businesses, this book that I’ve been writing again and again for over a decade has finally grown up.

It’s time to write PHP like the big kids do.

PHP & MySQL: Novice to Ninja is available for pre-order from SitePoint from $17. The digital version will be delivered May 1st, 2012.