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

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

XMLWordPrintable

    • Any
    • MOODLE_20_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • 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.

      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().

            Votes:
            19 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.