Geekery, Programming

Perhaps it is because of the recent slew of high profile SQL injection attacks, or perhaps because it was just finally time to bite the bullet and make the switch. PHP internal emails have revealed that there is finally an official movement to deprecate the ext/mysql and mysql_* family of functions from PHP.

For me, this couldn’t have come any sooner. Although the community has been advocating a change for a long time, much of the documentation and tutorials that exist on the Internet still point to using mysql_* functions instead of their more current alternatives. Many times throughout the day, nearly every day, new PHP developers ask questions in the ##php IRC chat on irc.freenode.net and are delivered a swift !+mysql is old indicating that:

mysql_* functions are no longer recommended for new development. For new projects use mysqli (php.net/mysqli) or PDO (php.net/PDO). The MySQL developers developed guidelines and a script for migrating your code http://forge.mysql.com/wiki/Converting_to_MySQLi. Most people here will recommend PDO: http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers

You can find the full email if you want to see the text in it’s entirety but the main points for suggesting things move along are:

  • Softly deprecate ext/mysql with education (docs) starting today
  • Not adding E_DEPRECATED errors in 5.4, but revisit for 5.5/6.0
  • Add pdo_mysql examples within the ext/mysql docs that mimic the current examples, but occasionally introduce features like prepared statements
  • Focus energy on cleaning up the pdo_mysql and mysqli documentation
  • Create a general “The MySQL situation” document that explains the situation

Which should you choose? Should you use PDO or mysqli?

The personal preference of this author is definitely PDO. The possibility of interoperability with other databases is nice, but ability to use exceptions to handle issues with the database is really the selling point for me. Exception handling and other features means that PDO is recommended more often than mysqli_* functions for new development. This is reflected in responses to the mailing list.

To educate yourself on the issue, you can check out additional information about the differences between the options in the PHP manual. For a quick overview, the table near the bottom of the page in the manual is a nice, quick reference:

  PHP's mysqli Extension PDO (Using PDO MySQL Driver and MySQL Native Driver) PHP's MySQL Extension
PHP version introduced 5.0 5.0 Prior to 3.0
Included with PHP 5.x yes yes Yes
MySQL development status Active development Active development as of PHP 5.3 Maintenance only
Recommended by MySQL for new projects Yes – preferred option Yes No
API supports Charsets Yes Yes No
API supports server-side Prepared Statements Yes Yes No
API supports client-side Prepared Statements No Yes No
API supports Stored Procedures Yes Yes No
API supports Multiple Statements Yes Most No
Supports all MySQL 4.1+ functionality Yes Most No

However, my opinion and the opinion of other PHP developers on the matter, may not make a huge difference when it comes to future development. Johannes Schl├╝ter, an engineer on the MySQL/Oracle team, responded to the PHP mailing list with some interesting information about which direction their team is headed:

I’m not sure the current PDO is “the” alternative. We (= MySQL/ORACLE) focus mostly on mysqli, that’s the extension providing access to all current and future features of MySQL. True, many features could be added to PDO but there are two design decision in PDO which make this bad:

  • The parser used for identifying statement place holders is very basic, as it is implemented in PDO core, not the drivers, which leads to FRs like #54929 or the famous LIKE issue.
  • driver-specific functions are implemented by using __call() which means there is no good introspection mechanism to check whether a feature is available or not in the current setup.

Besides these two items there are every now and then reports on PDO_mysql which in fact are caused by limitations in the PDO design which can’t be bypassed by the driver implementation.

A good abstraction layer would certainly be good for the language but for now we (=MySQL/ORACLE) consider mysqli the preference.

It sounds like we will have to wait and see which will be the accepted alternative for future development (if any is ever considered accepted). A huge tipping point would be adding exception handling in the mysqli_* family of functions but that doesn’t appear to be an important development direction at the moment. For now, I will continue to happily use PDO and await the day for users to start wondering why most of the MySQL/PHP tutorials on the web are throwing E_DEPRECATED warnings.

For more information about converting your code to use the new libraries or to learn about them, consider the following links:

It’s about time.

News, Technology

While we enjoy a great many things down here in the Virgin Islands, one of the things we do lack of is some of the common conveniences that many take for granted back on the mainland. One of those wonderful things was the introduction of Netflix streaming capabilities.

Having the ability to stream television shows and movies from Netflix is incredibly handy. Many of us pay for the DVD and/or Blu-Ray service already since it’s sort of a necessity considering our spotty coverage of movies that come out in the theater (another minor inconvenience). Those of us living in the Virgin Islands with a Netflix account were, understandably, a bit annoyed when we received and email back in November of 2010 about a rate increase. The reason?

Why the changes? Our selection of TV episodes and movies available to stream has grown dramatically, and as a result most members want us to deliver unlimited TV episodes and movies two ways: streaming instantly over the internet plus DVDs by mail. The price increase will allow us to continue to offer the popular plan choice of unlimited TV episodes and movies streaming instantly along with unlimited DVDs. The new plan, which does not include DVDs, is a great option for the increasing number of members who only want to watch instantly. The $7.99 a month price reflects no DVD shipping costs on this plan. – (source)

Netflix thought the streaming service was quite the bees knees, as well; to the tune of an additional $1.00 per month. They began offering a streaming only service so that should equal things out, right? Those of us who did not have streaming service noticed the distinct lack of a “disc only service.”

You can imagine, then, the delight when an email arrived in many of our inboxes towards the end of the day on the 30th of June:

Could it be true? Could Netflix really be offering streaming to the Virgin Islands now? A quick hop over to netflix.com and a small Silverlight install later proved that, indeed, Netflix was now streaming their content to the U.S. Virgin Islands.

Let’s just hope what little bandwidth we have on this island, doesn’t get sucked dry because of it.

Life, Programming, This Turbulent World

Well, it was time for a change. This blog has transitioned to it’s new permanent location here at Random Drake. There are events in our lives which cannot be foretold and thus, we move on and on in an effort to keep up with the inevitable force that drives us known as: change.

Moving the blog, setting up the new design and going through old content, allowed me to realize that it had been an entire year since I had the opportunity to publish something. I was saddened to know that a blog, I worked so hard to get up and going, was not getting the attention it deserved. Life is unfolding faster and faster in front of me and so I felt it necessary to bring this back to life. I enjoy the writings and pleasure that I received in sharing programming, news and events with the rest of the world. That being the case: you can expect a revival of content and stories from this particular blogger. I have personalized the blog in an effort to make it a part of my life and who I am instead of simply a place where I posted things occasionally.

My personal and professional lives have had a great deal of happenings in the last year. Moving to another part of the world has introduced me to a new job where I toil along an immense project that keeps me constantly busy. The database seems to practically be busting at the seams, compared to other projects, as it grows near 400GB in size. The project rewards me by allowing me to write some good PHP and increase my SQL skills tremendously.

The ongoing side project, that has been in development for a few years, has seen a revival since receiving a makeover. Surpassing half a million hits in a month was a pretty neat thing to see and allowed me to know it was something that should become more of a priority. Continuing to gain popularity, the site has a few more big steps going for it before my trip to California where I hope to start spreading the good word about it.

Continuing to work on getting this blog more accessible, interesting and connected is something I have a goal for. Hopefully I will be able to find some additional WordPress plugins to aid me in the task.

We shall see what happens as time goes on.