MDL-21437 data - number and date fields search under mssql and oracle
authorEloy Lafuente <stronk7@moodle.org>
Wed, 17 Nov 2010 17:54:00 +0000 (17:54 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Wed, 17 Nov 2010 17:54:00 +0000 (17:54 +0000)
mod/data/field/date/field.class.php
mod/data/field/number/field.class.php

index 8934ed7..313058c 100755 (executable)
@@ -64,10 +64,13 @@ class data_field_date extends data_field_base {
     }
 
     function generate_sql($tablealias, $value) {
+        global $DB;
+
         static $i=0;
         $i++;
-        $name = "df_picture_$i";
-        return array(" ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content = '$value') ", array($name=>"%$value%"));
+        $name = "df_date_$i";
+        $varcharcontent = $DB->sql_compare_text("{$tablealias}.content");
+        return array(" ({$tablealias}.fieldid = {$this->field->id} AND $varcharcontent = :$name) ", array($name=>$value));
     }
 
     function parse_search_field() {
index ee905ca..97f6510 100755 (executable)
@@ -79,10 +79,13 @@ class data_field_number extends data_field_base {
 
     // need to cast?
     function generate_sql($tablealias, $value) {
+        global $DB;
+
         static $i=0;
         $i++;
         $name = "df_number_$i";
-        return array(" ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content = :$name) ", array($name=>$value));
+        $varcharcontent = $DB->sql_compare_text("{$tablealias}.content");
+        return array(" ({$tablealias}.fieldid = {$this->field->id} AND $varcharcontent = :$name) ", array($name=>$value));
     }
 
     function get_sort_sql($fieldname) {