PHPCompatibility Code



Use the mysqli extension:

  • If the application uses an ORM, offers a mysqli adapter, you did not override anything in the mysql adapter, and you do not use any mysql_ functions outside the ORM. then you can simply switch the ORM's adapter.
  • Otherwise, create a compatibility class, such as MysqlToMysqli, to replicate mysql behavior in mysqli.

You could also switch to PDO, but that would require more effort because the differences are more pronounced.

Common Changes

One of the most obvious changes is that mysql_ functions magically used the last database connection, whereas mysqli_ functions need the connection object to be explicit.