Permalink
Browse files

MDL-35961 - mod/data: Removed duplicate data_content join in simple s…

…earches. Thanks to Patrick Pollet (patrick.pollet@insa-lyon.fr) for his patch
  • Loading branch information...
1 parent 6109f21 commit eb6e0c613d4a72c49acbb9e274c1353bed7aaaa2 @abgreeve abgreeve committed Oct 29, 2012
Showing with 6 additions and 8 deletions.
  1. +6 −8 mod/data/view.php
View
@@ -511,11 +511,10 @@
$what = ' DISTINCT r.id, r.approved, r.timecreated, r.timemodified, r.userid, u.firstname, u.lastname';
$count = ' COUNT(DISTINCT c.recordid) ';
- $tables = '{data_content} c,{data_records} r, {data_content} cs, {user} u ';
+ $tables = '{data_content} c,{data_records} r, {user} u ';
$where = 'WHERE c.recordid = r.id
AND r.dataid = :dataid
- AND r.userid = u.id
- AND cs.recordid = r.id ';
+ AND r.userid = u.id ';
$params['dataid'] = $data->id;
$sortorder = ' ORDER BY '.$ordering.', r.id ASC ';
$searchselect = '';
@@ -541,7 +540,7 @@
$advparams = array_merge($advparams, $val->params);
}
} else if ($search) {
- $searchselect = " AND (".$DB->sql_like('cs.content', ':search1', false)." OR ".$DB->sql_like('u.firstname', ':search2', false)." OR ".$DB->sql_like('u.lastname', ':search3', false)." ) ";
+ $searchselect = " AND (".$DB->sql_like('c.content', ':search1', false)." OR ".$DB->sql_like('u.firstname', ':search2', false)." OR ".$DB->sql_like('u.lastname', ':search3', false)." ) ";
$params['search1'] = "%$search%";
$params['search2'] = "%$search%";
$params['search3'] = "%$search%";
@@ -556,12 +555,11 @@
$what = ' DISTINCT r.id, r.approved, r.timecreated, r.timemodified, r.userid, u.firstname, u.lastname, ' . $sortcontentfull . ' AS sortorder ';
$count = ' COUNT(DISTINCT c.recordid) ';
- $tables = '{data_content} c, {data_records} r, {data_content} cs, {user} u ';
+ $tables = '{data_content} c, {data_records} r, {user} u ';
$where = 'WHERE c.recordid = r.id
AND c.fieldid = :sort
AND r.dataid = :dataid
- AND r.userid = u.id
- AND cs.recordid = r.id ';
+ AND r.userid = u.id ';
$params['dataid'] = $data->id;
$params['sort'] = $sort;
$sortorder = ' ORDER BY sortorder '.$order.' , r.id ASC ';
@@ -587,7 +585,7 @@
$advparams = array_merge($advparams, $val->params);
}
} else if ($search) {
- $searchselect = " AND (".$DB->sql_like('cs.content', ':search1', false)." OR ".$DB->sql_like('u.firstname', ':search2', false)." OR ".$DB->sql_like('u.lastname', ':search3', false)." ) ";
+ $searchselect = " AND (".$DB->sql_like('c.content', ':search1', false)." OR ".$DB->sql_like('u.firstname', ':search2', false)." OR ".$DB->sql_like('u.lastname', ':search3', false)." ) ";
$params['search1'] = "%$search%";
$params['search2'] = "%$search%";
$params['search3'] = "%$search%";

0 comments on commit eb6e0c6

Please sign in to comment.