Overview
What it is not
Although MariaDB Native Driver is written as a PHP extension, it is important to note that it does not provide a new API to the PHP programmer. The programmer APIs for MariaDB database connectivity are provided by the MariaDB extension, mysqli
and PDO MYSQL. These extensions can now use the services of MariaDB Native Driver to communicate with the MariaDB Server. Therefore, you should not think of MariaDB Native Driver as an API.
Why use it?
Using the MariaDB Native Driver offers a number of advantages over using the MariaDB Client Library.
The older MariaDB Client Library was written by MariaDB Foundation (now Oracle Corporation) and so was released under the MariaDB license. This ultimately led to MariaDB support being disabled by default in PHP. However, the MariaDB Native Driver has been developed as part of the PHP project, and is therefore released under the PHP license. This removes licensing issues that have been problematic in the past.
Also, in the past, you needed to build the MariaDB database extensions against a copy of the MariaDB Client Library. This typically meant you needed to have MariaDB installed on a machine where you were building the PHP source code. Also, when your PHP application was running, the MariaDB database extensions would call down to the MariaDB Client library file at run time, so the file needed to be installed on your system. With MariaDB Native Driver that is no longer the case as it is included as part of the standard distribution. So you do not need MariaDB installed in order to build PHP or run PHP database applications.
Because MariaDB Native Driver is written as a PHP extension, it is tightly coupled to the workings of PHP. This leads to gains in efficiency, especially when it comes to memory usage, as the driver uses the PHP memory management system. It also supports the PHP memory limit. Using MariaDB Native Driver leads to comparable or better performance than using MariaDB Client Library, it always ensures the most efficient use of memory. One example of the memory efficiency is the fact that when using the MariaDB Client Library, each row is stored in memory twice, whereas with the MariaDB Native Driver each row is only stored once in memory.
Special features
MySQL Native Driver also provides some special features not available when the MariaDB database extensions use MariaDB Client Library. These special features are listed below:
- Improved persistent connections
- The special function
mysqli_fetch_all
- Performance statistics calls:
mysqli_get_cache_stats
,mysqli_get_client_stats
,mysqli_get_connection_stats
The performance statistics facility can prove to be very useful in identifying performance bottlenecks.
MySQL Native Driver also allows for persistent connections when used with the mysqli
extension.
SSL Support
MySQL Native Driver has supported SSL since PHP version 5.3.3
Compressed Protocol Support
As of PHP 5.3.2 MariaDB Native Driver supports the compressed client server protocol. MariaDB Native Driver did not support this in 5.3.0 and 5.3.1. Extensions such as ext/mysql
, ext/mysqli
, that are configured to use MariaDB Native Driver, can also take advantage of this feature. Note that PDO_MYSQL
does NOT support compression when used together with mysqlnd.
Named Pipes Support
Named pipes support for Windows was added in PHP version 5.4.0.