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

count_records_sql does not return an integer

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.3, 2.3
    • Fix Version/s: 2.4
    • Component/s: Database SQL/XMLDB
    • Labels:

      Description

      The docblock above count_records_sql states that it returns an integer though this is not the case (unless the count is zero in which case an integer will be returned). Here is the current implementation:

      public function count_records_sql($sql, array $params=null) {
          if ($count = $this->get_field_sql($sql, $params)) {
              return $count;
          } else {
              return 0;
          }
      }

      It seems to me that this could be fixed/shorten to:

      public function count_records_sql($sql, array $params=null) {
          return (int)$this->get_field_sql($sql, $params);
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              skodak Petr Skoda
              Reporter:
              kyledecot Kyle Decot
              Integrator:
              Dan Poltawski
              Tester:
              Dan Poltawski
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                3/Dec/12