Add isMysql/isMariadb split helpers for MySQL-vs-MariaDB divergence

For the rare cases where SQL must differ between MySQL and MariaDB,
add DatabaseDriver::isMysql()/isMariadb() and db_is_mysql()/db_is_mariadb()
alongside the existing grouped isMysqlMaria()/db_is_mysql_maria().
pull/7271/head
Your Name 1 week ago
parent e3b6cebf27
commit 30440c5e00

@ -47,6 +47,28 @@ class DatabaseDriver
return in_array(self::name($connection), self::MYSQL_LIKE, true);
}
/**
* True when the driver is MySQL specifically (not MariaDB).
*
* Only use when the behaviour must differ between MySQL and MariaDB;
* otherwise prefer isMysqlMaria().
*/
public static function isMysql(?string $connection = null): bool
{
return self::name($connection) === 'mysql';
}
/**
* True when the driver is MariaDB specifically (not MySQL).
*
* Only use when the behaviour must differ between MySQL and MariaDB;
* otherwise prefer isMysqlMaria().
*/
public static function isMariadb(?string $connection = null): bool
{
return self::name($connection) === 'mariadb';
}
/**
* True when the driver is PostgreSQL.
*/

@ -23,6 +23,32 @@ if (! function_exists('db_is_mysql_maria')) {
}
}
if (! function_exists('db_is_mysql')) {
/**
* True when the connection uses MySQL specifically (not MariaDB).
*
* Only use when behaviour must differ between MySQL and MariaDB;
* otherwise prefer db_is_mysql_maria().
*/
function db_is_mysql(?string $connection = null): bool
{
return DatabaseDriver::isMysql($connection);
}
}
if (! function_exists('db_is_mariadb')) {
/**
* True when the connection uses MariaDB specifically (not MySQL).
*
* Only use when behaviour must differ between MySQL and MariaDB;
* otherwise prefer db_is_mysql_maria().
*/
function db_is_mariadb(?string $connection = null): bool
{
return DatabaseDriver::isMariadb($connection);
}
}
if (! function_exists('db_is_pgsql')) {
/**
* True when the active (or given) connection uses PostgreSQL.

Loading…
Cancel
Save