Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-14679 META: DB layer 2.0
  3. MDL-14861

Use proper placeholders for IN senteces

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Database SQL/XMLDB
    • Labels:
      None
    • Database:
      Any
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      While looking at code (accesslib.php), I've detected a lot of uses of IN() statements where the list of values continues being passed as comma-separated string.

      While it works... ideally all them should be converted to proper ? placeholders, correct?

      Pasting here the function used in Mahara (suggested by Penny):

      /**

      • function to convert an array to
      • an array of placeholders
      • with the right number of values
        *
      • @param array $array input array
        */
        function db_array_to_ph($array) {
        return array_pad(array(), count($array), '?');
        }

      note it's enough for us, needing to support :named parameters. And also note it returns an array and should return one string directly.

      Not checked if we have implemented this our way (it sounds to me that yes).

      Ciao

        Attachments

          Activity

            People

            • Assignee:
              skodak Petr Skoda
              Reporter:
              stronk7 Eloy Lafuente (stronk7)
              Participants:
              Component watchers:
              Jake Dallimore, Jun Pataleta, Ryan Wyllie
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                24/Nov/10