MDL-14463 search/order - comments cleanup + make it cross-db + delete unused column from query ; backported from HEAD

This commit is contained in:
stronk7
2009-05-06 17:26:34 +00:00
parent bee3f66eb0
commit 4d2cf40ef9
+1 -22
View File
@@ -307,7 +307,7 @@
$sortcontent = $sortfield->get_sort_field();
$sortcontentfull = $sortfield->get_sort_sql('c.'.$sortcontent);
$what = ' DISTINCT r.id, r.approved, r.userid, u.firstname, u.lastname, c.'.$sortcontent.', '.$sortcontentfull.' AS _order ';
$what = ' DISTINCT r.id, r.approved, r.userid, u.firstname, u.lastname, '.sql_compare_text($sortcontentfull).' AS _order ';
$count = ' COUNT(DISTINCT c.recordid) ';
$tables = $CFG->prefix.'data_content c,'.$CFG->prefix.'data_records r,'.$CFG->prefix.'data_content c1, '.$CFG->prefix.'user u ';
$where = 'WHERE c.recordid = r.id
@@ -371,27 +371,6 @@
$nowperpage = 1;
$mode = 'single';
# Following code needs testing to make it work
# if ($sort) { // We need to search by that field
# if ($content = get_field('data_content', 'content', 'recordid', $record->id, 'fieldid', $sort)) {
# $content = addslashes($content);
# if ($order == 'ASC') {
# $lessthan = " AND $sortcontentfull < '$content'
# OR ($sortcontentfull = '$content' AND r.id < '$record->id') ";
# } else {
# $lessthan = " AND $sortcontentfull > '$content'
# OR ($sortcontentfull = '$content' AND r.id < '$record->id') ";
# }
# } else { // Failed to find data (shouldn't happen), so fall back to something easy
# $lessthan = " r.id < '$record->id' ";
# }
# } else {
# $lessthan = " r.id < '$record->id' ";
# }
# $sqlindex = 'SELECT COUNT(DISTINCT c.recordid) '.$fromsql.$lessthan.$sortorder;
# $page = count_records_sql($sqlindex);
$allrecords = get_records_sql($sqlselect); // Kludgey but accurate at least!
$page = 0;
foreach ($allrecords as $key => $allrecord) {