From cdc4e97c7e15fd8d078a13fbafacbbe07d6432f2 Mon Sep 17 00:00:00 2001 From: bwdutton Date: Sun, 25 Feb 2018 10:12:11 -0800 Subject: [PATCH] Make queries work with sql_mode = 'ONLY_FULL_GROUP_BY' enabled in mysql --- modules/gallery/helpers/gallery_task.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index 618cf8fd..74896787 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -766,10 +766,10 @@ class gallery_task_Core { ->select_distinct( array("parent_slug" => db::expr("CONCAT(`parent_id`, ':', LOWER(`slug`))"))) ->select("id") - ->select(array("C" => "COUNT(\"*\")")) + ->select(array("C" => 'COUNT("*")')) ->from("items") - ->having("C", ">", 1) - ->group_by("parent_slug") + ->having('COUNT("*")', ">", 1) + ->group_by("parent_slug", "id") ->execute(); } @@ -779,10 +779,10 @@ class gallery_task_Core { ->select_distinct( array("parent_name" => db::expr("CONCAT(`parent_id`, ':', LOWER(`name`))"))) ->select("id") - ->select(array("C" => "COUNT(\"*\")")) + ->select(array("C" => 'COUNT("*")')) ->from("items") - ->having("C", ">", 1) - ->group_by("parent_name") + ->having('COUNT("*")', ">", 1) + ->group_by("parent_name", "id") ->execute(); } @@ -792,11 +792,11 @@ class gallery_task_Core { ->select_distinct( array("parent_base_name" => db::expr("CONCAT(`parent_id`, ':', LOWER(SUBSTR(`name`, 1, LOCATE('.', `name`) - 1)))"))) ->select("id") - ->select(array("C" => "COUNT(\"*\")")) + ->select(array("C" => 'COUNT("*")')) ->from("items") ->where("type", "<>", "album") - ->having("C", ">", 1) - ->group_by("parent_base_name") + ->having('COUNT("*")', ">", 1) + ->group_by("parent_base_name", "id") ->execute(); } @@ -823,4 +823,4 @@ class gallery_task_Core { ->limit($limit) ->execute(); } -} \ No newline at end of file +}