ext/mysql is so 2004
Posted 2013.01.08
About ten months ago, I started to update my website to use PHP server-side code and MySQL databases. As a complete newcomer, I didn't know how to do it; I just knew that building my own content management system would be a valuable learning experience, and it would make posting entries much easier than making and editing series of HTML files. I went to w3schools.com to learn PHP, and I skimmed sites like StackOverflow.com to learn how to put all that knowledge to blog-making use.

I'm proud of everything I learned in that process, but I overlooked something. For almost a year, the PHP guys had been working to deprecate a MySQL extension, ext/mysql. This extension, being the first and oldest, was used by a lot of tutorials that I read while learning PHP, to the extent that one StackOverflow commenter called it "w3schools syndrome". Because it was so prevalent, I only saw this extension, and not the newer ones, when I was learning the basics from tutorials about four or five years old. As a result, I didn't know I was learning a system that could no longer use the full benefits of MySQL. (Or I did, and I ignored it because I didn't get that "deprecating" meant "eventually, we aren't going to support it.")

So, it turns out I worked really hard to implement an old, currently deprecated, system. No matter, though; it still works, so I have time to switch everything to a newer extension. I'll be using ext/mysqli (MySQL Improved) because:

  1. It's what Oracle, the developers of MySQL, will use.
  2. The biggest thing I have to do is change function names.
  3. Most of the function name changes are very small, like
    mysql_data_seek() ↠ mysqli_data_seek()
  4. When I get more comfortable with it, I can transition from the current procedural code to object-oriented programming.

To be fair, the other extension available, PDO, can also be used for other database systems. Much of my reasoning, therefore, lies in points #3 and #4 (PDO does not have a procedural option). This is still new territory for me, so I'd like to stick with what I already know.

What I don't know is when I'll be updating the code, but my optimistic mind tells me it won't take long, so it'll probably go unannounced (especially since everything will still look the same).


HTML Comment Box is loading comments...