From 06f374b26b01674707c135843d0df5189a9e57cf Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 15 Apr 2017 14:39:41 +0200 Subject: [PATCH] Document any_value_fallback() https://github.com/friendica/friendica/pull/3323#discussion_r111663767 --- include/dba.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/include/dba.php b/include/dba.php index 665580124..4352cde66 100644 --- a/include/dba.php +++ b/include/dba.php @@ -507,12 +507,20 @@ function dbesc($str) { } } +/** + * @brief Replaces ANY_VALUE() function by MIN() function, + * if the database server does not support ANY_VALUE(). + * + * Considerations for Standard SQL, or MySQL with ONLY_FULL_GROUP_BY (default since 5.7.5). + * ANY_VALUE() is available from MySQL 5.7.5 https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html + * A standard fall-back is to use MIN(). + * + * @param string $sql An SQL string without the values + * @return string The input SQL string modified if necessary. + */ function any_value_fallback($sql) { global $db; $server_info = $db->server_info(); - //Considerations for Standard SQL, or MySQL with ONLY_FULL_GROUP_BY (default since 5.7.5). - //ANY_VALUE() is available from MySQL 5.7.5 https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html - //A standard fallback is to use MIN() if (version_compare($server_info, '5.7.5', '<') || (stripos($server_info, 'MariaDB') !== false)) { $sql = str_ireplace('ANY_VALUE(', 'MIN(', $sql);