login
PHP 5.5+ mysql native extension deprecation posted: Thu 2013-03-14 19:56:02 tags: tech
As of PHP 5.5.0, the "native" (or "original") MySQL extension is will be deprecated. PHP 5.4.12 was released 2013-02-21; we're not up to v5.5 yet; and due to massive deployment of applications that depend on the native MySQL extension, I don't foresee it going unsupported anytime soon. But deprecation is what it is, which means Phosphoros, as well as the sites I maintain for my jorb, are that much less future-proof.

The MySQL extension provides the mysql_* language constructs:

  • mysql_real_escape_string()
  • mysql_connect()
  • mysql_query()
  • mysql_fetch_array()
  • mysql_affected_rows()
  • ...and so on.

    There are two alternatives: the MySQL "improved" extension (aka mysqli), or the PDO extension. This NetTuts article examines the differences more digestibly than slogging through the PHP.net documentation, searching for feature comparisons.

    For starters, the mysql "native" extension was accessible with comfortable old procedural syntax. "Improved" mysqli is too; PDO requires object-oriented syntax. So if extensive code revision is a problem, mysqli is the way to go. mysqli also marginally outperforms PDO... but performance speed is a cheap problem to fix if code is well-written.

    Both support query parameterization, which makes coding neater and eliminates SQL injection concerns. So that's something you'd want to standardize on either way. PDO specifically supports named parameters, which makes for even more comprehensible code.

    PDO is undeniably the more powerful/flexible, with support for multiple database drivers. This suggests forward-compatibility as MySQL itself mutates. With the deprecation of the original mysql extension, mysqli will be positioned as the "current" MySQL extension, and it's not hard to imagine it going the same route toward deprecation as MySQL mutates.