]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
MySQL ANY_VALUE with fallback to MIN
[friendica.git] / include / api.php
index 477eb94b4e55de8026fa805266d2e802dfd64f6d..75f8ab069a83b1d4f8286d0183f1017d533c3ee2 100644 (file)
@@ -3099,13 +3099,14 @@ use \Friendica\Core\Config;
 
                $scale = (x($_REQUEST, 'scale') ? intval($_REQUEST['scale']) : false);
                $scale_sql = ($scale === false ? "" : sprintf("and scale=%d",intval($scale)));
-               $data_sql = ($scale === false ? "" : "data, ");
-
-               $r = q("select %s `resource-id`, `created`, `edited`, `title`, `desc`, `album`, `filename`,
-                                       `type`, `height`, `width`, `datasize`, `profile`, min(`scale`) as minscale, max(`scale`) as maxscale
-                               from photo where `uid` = %d and `resource-id` = '%s' %s
-                               group by `resource-id`, `created`, `edited`, `title`, `desc`, `album`, `filename`,
-                                       `type`, `height`, `width`, `datasize`, `profile`",
+               $data_sql = ($scale === false ? "" : "ANY_VALUE(data) AS data,");
+
+               $r = q("select %s ANY_VALUE(`resource-id`) AS `resource-id`, ANY_VALUE(`created`) AS `created`,
+                               ANY_VALUE(`edited`) AS `edited`, ANY_VALUE(`title`) AS `title`, ANY_VALUE(`desc`) AS `desc`,
+                               ANY_VALUE(`album`) AS `album`, ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`type`) AS `type`,
+                               ANY_VALUE(`height`) AS `height`, ANY_VALUE(`width`) AS `width`, ANY_VALUE(`datasize`) AS `datasize`,
+                               ANY_VALUE(`profile`) AS `profile`, min(`scale`) as minscale, max(`scale`) as maxscale
+                               from photo where `uid` = %d and `resource-id` = '%s' %s",
                        $data_sql,
                        intval(local_user()),
                        dbesc($_REQUEST['photo_id']),