From 30440c5e00af930b588de05b51df9df2d878956b Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 14 Sep 2026 15:33:20 +0930 Subject: [PATCH] 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(). --- app/Util/Database/DatabaseDriver.php | 22 ++++++++++++++++++++++ app/helpers.php | 26 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/app/Util/Database/DatabaseDriver.php b/app/Util/Database/DatabaseDriver.php index 2d3223896..8ceb93b28 100644 --- a/app/Util/Database/DatabaseDriver.php +++ b/app/Util/Database/DatabaseDriver.php @@ -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. */ diff --git a/app/helpers.php b/app/helpers.php index 37af3f949..b820136c0 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -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.