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

Allow comparison on text fields in $DB->get_record() and delete_record()

    XMLWordPrintable

    Details

    • Database:
      Any
    • Testing Instructions:
      Hide

      Write a call to $DB->get_record() where one of the fields of the params array is a text field.

      Show
      Write a call to $DB->get_record() where one of the fields of the params array is a text field.
    • Affected Branches:
      MOODLE_20_STABLE

      Description

      As detailed in this discussion: http://moodle.org/mod/forum/discuss.php?d=176081

      When using $DB->get_record() to compare text field with a value, the following error is produced:
      Comparisons of text column conditions are not allowed. Please use sql_compare_text() in your query.

      As you don't write the SQL yourself when using get_record(), this message is useless.
      Either get_record should make appropriate use of sql_compare_text() to cirumvent the problem for you,
      Or the error message should be a coding error telling you to use a more appropriate $DB method such as get_record_select, allowing you to specify a where clause using sql_compare_text().

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              marxjohnson Mark Johnson
              Participants:
              Component watchers:
              Andrew Nicols, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              15 Vote for this issue
              Watchers:
              10 Start watching this issue

                Dates

                Created:
                Updated: