Permalink
Browse files

MDL-25692 search working for mssql + oracle

  • Loading branch information...
1 parent 5dd05d5 commit 3751c84008fccfa2dc2f7d14e205d1159fe06de7 @stronk7 stronk7 committed Dec 16, 2010
View
6 mod/data/field/checkbox/field.class.php
@@ -113,17 +113,18 @@ function parse_search_field() {
}
return array('checked'=>$selected, 'allrequired'=>$allrequired);
}
-
+
function generate_sql($tablealias, $value) {
$allrequired = $value['allrequired'];
$selected = $value['checked'];
+ $varcharcontent = sql_compare_text("{$tablealias}.content", 255);
if ($selected) {
$conditions = array();
foreach ($selected as $sel) {
$likesel = str_replace('%', '\%', $sel);
$likeselsel = str_replace('_', '\_', $likesel);
- $conditions[] = "({$tablealias}.fieldid = {$this->field->id} AND ({$tablealias}.content = '$sel'
+ $conditions[] = "({$tablealias}.fieldid = {$this->field->id} AND ($varcharcontent = '$sel'
OR {$tablealias}.content LIKE '$likesel##%'
OR {$tablealias}.content LIKE '%##$likesel'
OR {$tablealias}.content LIKE '%##$likesel##%'))";
@@ -138,7 +139,6 @@ function generate_sql($tablealias, $value) {
}
}
-
function update_content($recordid, $value, $name='') {
$content = new object();
$content->fieldid = $this->field->id;
View
4 mod/data/field/latlong/field.class.php
@@ -93,7 +93,9 @@ function generate_sql($tablealias, $value) {
$latlong[0] = '';
$latlong[1] = '';
$latlong = explode (',', $value, 2);
- return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content = '$latlong[0]' AND {$tablealias}.content1 = '$latlong[1]') ";
+ $varcharlat = sql_compare_text("{$tablealias}.content");
+ $varcharlong= sql_compare_text("{$tablealias}.content1");
+ return " ({$tablealias}.fieldid = {$this->field->id} AND $varcharlat = '$latlong[0]' AND $varcharlong = '$latlong[1]') ";
}
function display_browse_field($recordid, $template) {
View
3 mod/data/field/menu/field.class.php
@@ -97,7 +97,8 @@ function parse_search_field() {
}
function generate_sql($tablealias, $value) {
- return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content = '$value') ";
+ $varcharcontent = sql_compare_text("{$tablealias}.content", 255);
+ return " ({$tablealias}.fieldid = {$this->field->id} AND $varcharcontent = '$value') ";
}
}
View
3 mod/data/field/multimenu/field.class.php
@@ -140,13 +140,14 @@ function parse_search_field() {
function generate_sql($tablealias, $value) {
$allrequired = $value['allrequired'];
$selected = $value['selected'];
+ $varcharcontent = sql_compare_text("{$tablealias}.content", 255);
if ($selected) {
$conditions = array();
foreach ($selected as $sel) {
$likesel = str_replace('%', '\%', $sel);
$likeselsel = str_replace('_', '\_', $likesel);
- $conditions[] = "({$tablealias}.fieldid = {$this->field->id} AND ({$tablealias}.content = '$sel'
+ $conditions[] = "({$tablealias}.fieldid = {$this->field->id} AND ($varcharcontent = '$sel'
OR {$tablealias}.content LIKE '$likesel##%'
OR {$tablealias}.content LIKE '%##$likesel'
OR {$tablealias}.content LIKE '%##$likesel##%'))";
View
6 mod/data/field/number/field.class.php
@@ -76,10 +76,10 @@ function display_search_field($value = '') {
function parse_search_field() {
return optional_param('f_'.$this->field->id, '', PARAM_NOTAGS);
}
-
- // need to cast?
+
function generate_sql($tablealias, $value) {
- return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content = '$value') ";
+ $varcharcontent = sql_compare_text("{$tablealias}.content");
+ return " ({$tablealias}.fieldid = {$this->field->id} AND $varcharcontent = '$value') ";
}
function get_sort_sql($fieldname) {
View
3 mod/data/field/radiobutton/field.class.php
@@ -91,7 +91,8 @@ function parse_search_field() {
}
function generate_sql($tablealias, $value) {
- return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content = '$value') ";
+ $varcharcontent = sql_compare_text("{$tablealias}.content", 255);
+ return " ({$tablealias}.fieldid = {$this->field->id} AND $varcharcontent = '$value') ";
}
}
View
12 mod/data/field/text/field.class.php
@@ -29,19 +29,19 @@ class data_field_text extends data_field_base {
function data_field_text($field=0, $data=0) {
parent::data_field_base($field, $data);
}
-
+
function display_search_field($value = '') {
- return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
+ return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
}
-
+
function parse_search_field() {
return optional_param('f_'.$this->field->id, '', PARAM_NOTAGS);
}
-
+
function generate_sql($tablealias, $value) {
- return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content LIKE '%{$value}%') ";
+ return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content LIKE '%{$value}%') ";
}
-
+
}
?>
View
14 mod/data/field/textarea/field.class.php
@@ -68,20 +68,20 @@ function display_add_field($recordid=0) {
$str .= '</div>';
return $str;
}
-
-
+
+
function display_search_field($value = '') {
- return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
+ return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
}
-
+
function parse_search_field() {
return optional_param('f_'.$this->field->id, '', PARAM_NOTAGS);
}
-
+
function generate_sql($tablealias, $value) {
- return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content LIKE '%{$value}%') ";
+ return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content LIKE '%{$value}%') ";
}
-
+
function gen_textarea($usehtmleditor, $text='') {
// MDL-16018: Don't print htmlarea with < 7 lines height, causes visualization problem
$text = clean_text($text);

0 comments on commit 3751c84

Please sign in to comment.