This post will discuss an alternative driver for accessing MySQL, through PHP. His name is MySQL Native Driver.
There are three APIs for working with MySQL in PHP:
mysql ,
mysqli and
PDO . All three are implemented as extensions in C.
The oldest of these APIs is
mysql . This extension appeared in PHP 3 and perfectly supported versions of MySQL earlier than 4.1 (version <4.1). With older versions (> = 4.1) there are some difficulties. The
mysql API simply does not support some of the features of the new versions of MySQL.
Then came the
mysqli extension (probably
mysql improved ). This API supports all the new features of MySQL. Plus,
mysqli allows you to use OPP syntax along with procedural. The
mysqli extension comes with PHP since version 5.
')
The third API is called
PDO (PHP Data Objects). In a general sense, this is not only an API to MySQL, but also a certain layer of abstraction from a specific DBMS. As already mentioned,
PDO is supplied as an extension to PHP. So, along with this extension, drivers for specific DBMS are supplied: starting from SQLite and ending with Oracle.
These APIs are united by the fact that they use the same library to communicate directly with MySQL. They use the standard MySQL client library (
libmysql ). This library is written in C, and, by the way, is used not only for client applications in PHP, but also for Perl, C / C ++, Ruby, etc.
So, for a long time (it seems from the beginning of 2007) there is an opportunity to use MySQL Native Driver (
mysqlnd ). What it is? Conceptually, this is a replacement for
libmysql . And it is not for nothing that it is “Native” (native, embedded), since its entire implementation is closely intertwined with PHP (at the C level, of course) and distributed in accordance with the PHP license.
Actually the beauty is that since PHP5.3 / 6
mysqlnd comes to replace
libmysql . In this case, the API will not be affected in any way, and for the developer the transition process promises to be transparent - all the code written earlier using the API
mysql ,
mysqli and
PDO will work like a clock.
Schematically, it looks like this:

The advantages of the MySQL Native Driver come from its nature, which is closely related to the internals of PHP.
mysqlnd uses some of the built-in PHP functions, which can not but affect performance.
In any case, the study of the insides of MySQL Native Driver as well as its advantages deserve a separate note or even an article.
I hope that this introductory note about MySQL Native Driver will be useful to you at least a little.