Choosing a library
The mysqli, PDO_MySQL and mysql PHP extensions are lightweight wrappers on top of a C client library. The extensions can either use the mysqlnd library or the libmysqlclient library. Choosing a library is a compile time decision.
The mysqlnd library is part of the PHP distribution since 5.3.0. It offers features like lazy connections and query caching, features that are not available with libmysqlclient, so using the built-in mysqlnd library is highly recommended. See the mysqlnd documentation for additional details, and a listing of features and functionality that it offers.
Example #1 Configure commands for using mysqlnd or libmysqlclient
// Recommended, compiles with mysqlnd $ ./configure --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mysql=mysqlnd // Alternatively recommended, compiles with mysqlnd as of PHP 5.4 $ ./configure --with-mysqli --with-pdo-mysql --with-mysql // Not recommended, compiles with libmysqlclient $ ./configure --with-mysqli=/path/to/mysql_config --with-pdo-mysql=/path/to/mysql_config --with-mysql=/path/to/mysql_config
Library feature comparison
It is recommended to use the mysqlnd library instead of the MySQL Client Server library (libmysqlclient). Both libraries are supported and constantly being improved.
MySQL native driver (mysqlnd) | MySQL client server library (libmysqlclient) | |
---|---|---|
Part of the PHP distribution | Yes | No |
PHP version introduced | 5.3.0 | N/A |
License | PHP License 3.01 | Dual-License |
Development status | Active | Active |
Lifecycle | No end announced | No end announced |
PHP 5.4 and above; compile default (for all MySQL extensions) | Yes | No |
PHP 5.3; compile default (for all MySQL extensions) | No | Yes |
Compression protocol support | Yes (5.3.1+) | Yes |
SSL support | Yes (5.3.3+) | Yes |
Named pipe support | Yes (5.3.4+) | Yes |
Non-blocking, asynchronous queries | Yes | No |
Performance statistics | Yes | No |
LOAD LOCAL INFILE respects the open_basedir directive | Yes | No |
Uses PHP's native memory management system (e.g., follows PHP memory limits) | Yes | No |
Return numeric column as double (COM_QUERY) | Yes | No |
Return numeric column as string (COM_QUERY) | Yes | Yes |
Plugin API | Yes | Limited |
Read/Write splitting for MySQL Replication | Yes, with plugin | No |
Load Balancing | Yes, with plugin | No |
Fail over | Yes, with plugin | No |
Lazy connections | Yes, with plugin | No |
Query caching | Yes, with plugin | No |
Transparent query manipulations (E.g., auto-EXPLAIN or monitoring) | Yes, with plugin | No |
Automatic reconnect | No | Optional |
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-mysqlinfo.library.choosing.html/.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.