Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-64526

groups_get_all_groups(): SQL error when parameter $withmembers = true

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 3.5.3
    • Fix Version/s: None
    • Component/s: Groups
    • Labels:
      None

      Description

      Maybe I wrong, but when I set parameter $withmembers to TRUE  :

      groups_get_all_groups($cm->course, 0, $cm->groupingid, 'g.*', TRUE)

      Result says "Unknown column 'g.id' in 'on clause"

      In SQL, this "FROM" section generated don't work:

      FROM mdl_groups g , mdl_groupings_groups gg LEFT JOIN mdl_groups_members ugm ON ugm.groupid = g.id

      This SQL work (for us):

      FROM mdl_groups g inner join mdl_groupings_groups gg on g.id = gg.groupid
       LEFT JOIN mdl_groups_members ugm ON ugm.groupid = g.id

      So I think file lib/grouplib.php > function groups_get_all_groups() needs a little fix (ln 254-255):

      if (!empty($groupingid)) {
      // $groupingfrom = ", {groupings_groups} gg";
      // $groupingwhere = "AND g.id = gg.groupid AND gg.groupingid = ?";
       $groupingfrom = "INNER JOIN {groupings_groups} gg ON g.id = gg.groupid";
       $groupingwhere = "AND gg.groupingid = ?";

      Edit:
      And just before:

      if (empty($userid)) {
       $userfrom = "";
       $userwhere = "";
       $params = array();
       } else {
       list($usql, $params) = $DB->get_in_or_equal($userid);
      // $userfrom = ", {groups_members} gm";
      // $userwhere = "AND g.id = gm.groupid AND gm.userid $usql";
       $userfrom = "INNER JOIN {groups_members} gm ON g.id = gm.groupid";
       $userwhere = "AND gm.userid $usql";
       }

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rezaie9 Shamim Rezaie
                Reporter:
                philippematabiau Philippe Matabiau
                Peer reviewer:
                Tim Hunt
                Participants:
                Component watchers:
                Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: