Porting Code and Migrating Databases
Although the new mysqli
extension has many benefits over the older extension, they come at a
cost. Depending upon your code, porting to the new extension can be a
surprisingly tiresome task. If you’ve used a
database abstraction layer—such as
PEAR DB, ADOdb, or MDB—this task is
simplified considerably. Even though you’re only
switching from one version of MySQL to another, the new extension is
sufficiently different that quite a bit of work is necessary to make
the switch.
However, you probably will want to use mysqli
for
your new projects, and that requires an upgrade to MySQL 4.1. Since
an out-of-the-box MySQL 4.1 is incompatible with
mysql
, this presents a bit of a dilemma. You want
the benefits of mysqli
without worrying about
legacy code.
Another option is just to make the switch to a
database abstraction layer. This has some
advantages and some disadvantages. The primary benefit is
portability, but this comes at a cost of speed and features. For
instance, you cannot bind output parameters with PEAR DB, nor does DB
support all of the latest MySQLi options, such as
mysqli_multi_query( )
and ssl_set( )
.
This section presents a variety of options for handling the conversion process. Each one has various positive and negative attributes. Some require more hours of work; others are faster to implement, but at a cost of execution speed. None of these solutions are bad in and of themselves, but, given certain circumstances, some should be preferable ...
Get Upgrading to PHP 5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.