Chapter 3. MySQL
PHP
5
sports a new MySQL extension. While this extension is similar in
spirit to the original MySQL extension, it has many new features and
other improvements. To differentiate it from the original version,
this extension is called the “Improved MySQL
extension,” or mysqli
for short.
The changes to mysqli
come from two places. The majority are from new features available in
MySQL 4.1. However, PHP 5 also allows
mysqli
to add an object-oriented interface.
Here’s a list of the major advances in
mysqli
:
Compatibility with MySQL 4.1 and above
Prepared statements and bound parameters
Object-oriented interface
Secure connections using SSL
Additionally, MySQL 4.1 has new SQL-level capabilities that you can use from PHP. They include:
Subselects
Transactions
Fulltext searching
Unicode support
Geospacial support (GIS)
On the downside, there are a few wrinkles if you want to start using
mysqli
with your existing PHP projects:
Its client libraries are not bundled with PHP 5.
It does not work with MySQL 4.0 and below.
It’s missing some
mysql
functions.
In
a nutshell, if all your projects use MySQL 4.1 and later, and you
have no legacy MySQL code, then all you need to do is download the
MySQL client libraries and start using mysqli
. On
the other hand, you’ll have some work to do if you:
Want to use MySQL 4.1, but have existing
mysql
-based codeMust write code that runs under MySQL 4.0 (and below) and 4.1 (and above)
Want to have some applications use a MySQL 4.0 database and others use ...
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.