View Categories

PHP 5.5 Deprecates MySQL Functions

  • Dec 19, 2012
  • 0
  • by A2 Marketing Team

The release of PHP 5.5 has been announced, and it will be deprecating the old standard MySQL functions (such as mysql_query). It’s been known that this was coming for a while, and developers have been encouraged to migrate to MySQLi or PDO, but many haven’t. If you’ve been putting it off, it’s probably time to make the jump before moving to PHP 5.5. Of course the MySQL functions will still work in 5.5 but you’ll have to suppress the deprecated warnings.

So should you go with MySQLi or PDO? PDO (PHP Data Objects) provides more flexibility and abstraction. If you anticipate ever wanting to change the underlying database to anything other than MySQL, PDO is definitely the right choice. PDO’s abstraction layer isolates your code from the underlying database, meaning you can switch to Postgres, Oracle or other options without needing to alter all your database code.

On the other hand, if you’re unavoidably tied to MySQL and want a little more direct access to MySQL itself, going with MySQLi objects might make sense. In a lot of ways, MySQLi can simply be viewed as an object oriented version of the old MySQL functions. Much of the same functionality is present but via object methods instead of standalone functions.

If you’re unsure, erring on the side of PDO will give you more options in the future and is probably a safe default choice. Either way, if you’re currently using the old MySQL functions you have a little work ahead of you and it’s better not to put it off until PHP actually gets rid of those functions in a future version.

Looking for PHP 5.5 Hosting? Click here to get high performance PHP 5.5 Hosting from A2 Hosting.

The A2 Posting