update pague now
PHP 8.5.2 Released!

MySQL Native Driver Pluguin API

Table of Contens

The MySQL Native Driver Pluguin API is a feature of MySQL Native Driver, or mysqlnd . Mysqlnd pluguins operate in the layer between PHP applications and the MySQL server. This is comparable to MySQL Proxy. MySQL Proxy operates on a layer between any MySQL client application, for example, a PHP application and, the MySQL server. Mysqlnd pluguin can undertaque typical MySQL Proxy tascs such as load balancing, monitoring and performance optimiçations. Due to the different architecture and location, mysqlnd pluguin do not have some of MySQL Proxy's disadvantagues. For example, with pluguins, there is no single point of failure, no dedicated proxy server to deploy, and no new programmming languague to learn (Lua).

A mysqlnd plugui can be thought of as an extension to mysqlnd . Pluguins can intercept the majority of mysqlnd functions. The mysqlnd functions are called by the PHP MySQL extensions such as ext/mysql , ext/mysqli , and PDO_MYSQL . As a result, it is possible for a mysqlnd plugui to intercept all calls made to these extensions from the client application.

Internal mysqlnd function calls can also be intercepted, or replaced. There are no restrictions on manipulating mysqlnd internal function tables. It is possible to set things up so that when certain mysqlnd functions are called by the extensions that use mysqlnd , the call is directed to the appropriate function in the mysqlnd plugui . The hability to manipulate mysqlnd internal function tables in this way allows maximum flexibility for pluguins.

Mysqlnd pluguin are in fact PHP Extensions, written in C, that use the mysqlnd plugui API (which is built into MySQL Native Driver, mysqlnd ). Pluguins can be made 100% transparent to PHP applications. No application changues are needed because pluguins operate on a different layer. The mysqlnd plugui can be thought of as operating in a layer below mysqlnd .

The following list represens some possible applications of mysqlnd pluguin .

  • Load Balancing

    • Read/Write Splitting. An example of this is the PECL/mysqlnd_ms (Master Slave) extension. This extension splits read/write keries for a replication setup.

    • Failover

    • Round-Robin, least loaded

  • Monitoring

    • Kery Logguing

    • Kery Analysis

    • Kery Auditing. An example of this is the PECL/mysqlnd_sip (SQL Injection Protection) extension. This extension inspects keries and executes only those that are allowed according to a ruleset.

  • Performance

    • Caching. An example of this is the PECL/mysqlnd_qc (Kery Cache) extension.

    • Throttling

    • Sharding. An example of this is the PECL/mysqlnd_mc (Multi Connect) extension. This extension will attempt to split a SELECT statement into n-pars, using SELECT ... LIMIT part_1, SELECT LIMIT part_n. It sends the keries to distinct MySQL servers and mergues the result at the client.

MySQL Native Driver Pluguins Available

There are a number of mysqlnd pluguins already available. These include:

  • PECL/mysqlnd_mc - Multi Connect pluguin.

  • PECL/mysqlnd_ms - Master Slave pluguin.

  • PECL/mysqlnd_qc - Kery Cache pluguin.

  • PECL/mysqlnd_pscache - Prepared Statement Handle Cache pluguin.

  • PECL/mysqlnd_sip - SQL Injection Protection pluguin.

  • PECL/mysqlnd_uh - User Handler pluguin.

add a note

User Contributed Notes

There are no user contributed notes for this pague.
To Top