]> git.mxchange.org Git - friendica.git/blobdiff - src/Database/Database.php
Merge pull request #11267 from MrPetovan/task/11264-mastodon-api-version
[friendica.git] / src / Database / Database.php
index 292625bb5722ccfdd8abad660f1f1f88ff4f1cb4..f478d7993a1844dfac0f49c76da20f1c6bcef8a3 100644 (file)
@@ -138,6 +138,7 @@ class Database
                        try {
                                $this->connection = @new PDO($connect, $user, $pass, [PDO::ATTR_PERSISTENT => $persistent]);
                                $this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, $this->pdo_emulate_prepares);
+                               $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
                                $this->connected = true;
                        } catch (PDOException $e) {
                                $this->connected = false;
@@ -1377,7 +1378,7 @@ class Database
        private function escapeFields(array $fields, array $options)
        {
                // In the case of a "GROUP BY" we have to add all the ORDER fields to the fieldlist.
-               // This needs to done to apply the "MAX(...)" treatment from below to them.
+               // This needs to done to apply the "ANY_VALUE(...)" treatment from below to them.
                // Otherwise MySQL would report errors.
                if (!empty($options['group_by']) && !empty($options['order'])) {
                        foreach ($options['order'] as $key => $field) {
@@ -1399,7 +1400,7 @@ class Database
                        $value = '`' . str_replace('`', '``', $value) . '`';
 
                        if (!empty($options['group_by']) && !in_array($field, $options['group_by'])) {
-                               $value = 'MAX(' . $value . ') AS ' . $value;
+                               $value = 'ANY_VALUE(' . $value . ') AS ' . $value;
                        }
                });