MariaDB started as a fork of MySQL, and the two still use the same client protocol, so PHP talks to both through the same extensions. MariaDB has since added features MySQL doesn't have, and PHP can't reach most of them today. This RFC from Georg Richter would add some of them to mysqlnd, the low-level driver, and to mysqli, which is built on top of it.

What it adds

The RFC has three main parts:

  • Server detection. PHP would check the connection's capability flags to tell MariaDB from MySQL. The version string isn't reliable, since cloud hosts and proxies often rewrite it. New server_capabilities and ext_server_capabilities properties would expose the flags.
  • Bulk execution. A new execute_many() method runs one prepared statement for many rows at once. It works with INSERT, UPDATE, REPLACE and DELETE.
  • Progress reports. A new MYSQLI_OPT_PROGRESS_CALLBACK option gives you progress updates during long-running statements, like a big ALTER TABLE.

Show me

Here is a bulk insert from the RFC:

$rows = [
    ["Jennifer", 20.34],
    ["Marcus", 21.9],
    ["Zak", 20.91]
];

$stmt = $link->prepare("INSERT INTO t1 (name, score) VALUES (?, ?)");
$stmt->execute_many($rows);

You can also pass a generator, so only one row sits in memory at a time. The RFC pitches this as a safer alternative to LOAD DATA LOCAL INFILE, which many servers disable.

A new mysqli_indicator enum lets you mark a value in a row as Null, Default or Ignore.

The RFC's own benchmarks show large gains. Over a network, a bulk insert ran 106 times faster than a loop of execute() calls, and on the same machine it ran about 9 times faster.

What it means for existing code

Nothing breaks. The RFC adds new methods and options without changing existing ones.

execute_many() still works on MySQL, but it runs each row one at a time. In that case each row is its own transaction unless you start one yourself. The Default and Ignore indicators throw a mysqli_sql_exception on MySQL.

PDO_MySQL isn't covered. The author says PDO would need its own RFC.

Where it stands

The RFC is under discussion, and there's no vote on the page yet. A proof of concept targets PHP 8.6 and requires MariaDB 10.2 or newer.