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

user_picture::fields() cannot be used multiple times within one query

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: STABLE backlog
    • Fix Version/s: 2.0.2
    • Component/s: Libraries
    • Labels:
      None
    • Database:
      Any
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      The static method user_picture::fields() can't be used multiple times within one query because only 'id' field can be aliased. There is no way to provide aliases for them. That is a real usage blocker for all queries that join user table twice or more.

      I suggest to add yet another optional parameter to the function $fieldprefix=''. If it is present, all returned fields will be aliased using the value as prefix. This would apply to all the fileds but 'id' - alias of it can be set separately or even it can be left unaliased.

      When this is implemented, the method can can be used to generate SQL's like

      SELECT c.id AS contribid,
             a.id AS authorid,a.picture AS authorpicture,a.firstname AS authorfirstname,a.lastname AS authorlastname,a.imagealt AS authorimagealt,a.email AS authoremail,
             m.id AS maintainerid,m.picture AS maintainerpicture,m.firstname AS maintainerfirstname,m.lastname AS maintainerlastname,m.imagealt AS maintainerimagealt,m.email
        FROM {amos_contributions} c
        JOIN {user} a ON c.authorid = a.id
        JOIN {user} m ON c.maintainer = m.id

        Attachments

          Activity

            People

            Assignee:
            mudrd8mz David Mudrák (@mudrd8mz)
            Reporter:
            mudrd8mz David Mudrák (@mudrd8mz)
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              21/Feb/11