From: stronk7 Date: Fri, 14 May 2004 17:23:42 +0000 (+0000) Subject: Reverted to revision 1.8 (left join) to continue working in bug 985. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5cca2496459f9f68fa9e994c639aa4c697b7119a;p=moodle.git Reverted to revision 1.8 (left join) to continue working in bug 985. --- diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php index 5321d769dc..4e76635528 100644 --- a/mod/glossary/sql.php +++ b/mod/glossary/sql.php @@ -9,8 +9,6 @@ /// Creating the SQL statements - $calculatedrows = array(); - /// Pivot is the field that set the break by groups (category, initial, author name, etc) /// fullpivot indicate if the whole pivot should be compared agasint the db or just the first letter @@ -171,43 +169,10 @@ break; case 'term': - //Here we are going to use two selects to do the work and then mix the results - //due to differences about the left join implementation in some versions of MySQL - //When MySQL 4.1 become the minimum to Moodle, we must change this again - //to use the UNION operator!! - - $concepts = get_records_sql("$sqlselect - FROM {$CFG->prefix}glossary_entries ge - WHERE (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) AND - (ge.approved != 0 $userid) AND - (ge.concept = '$hook')"); - - if (empty($concepts)) { - $concepts = get_records_sql("$sqlselect - FROM {$CFG->prefix}glossary_entries ge, - {$CFG->prefix}glossary_alias al - WHERE (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) AND - (ge.approved != 0 $userid) AND - (ge.id = al.entryid) AND - (al.alias = '$hook')"); - } - - if (!empty($concepts)) { - foreach ($concepts as $concept) { - $calculatedrows[] = $concept; - break; - } - } - $printpivot = 0; - - //Here I leave previous code left join. Someday code above will be deleted and code below - //wil be changed to a standard UNION statement. No it's only executed if $calculatedrows is empty - if (empty($calculatedrows)) { - $sqlfrom .= " left join {$CFG->prefix}glossary_alias ga on ge.id = ga.entryid "; - $where = "AND (ge.concept = '$hook' OR ga.alias = '$hook' ) - "; - } + $sqlfrom .= " left join {$CFG->prefix}glossary_alias ga on ge.id = ga.entryid "; + $where = "AND (ge.concept = '$hook' OR ga.alias = '$hook' ) + "; break; case 'entry': @@ -243,14 +208,8 @@ break; } break; - } - - //If there are calculatedrows, use them - if (!empty ($calculatedrows)) { - $count = count($calculatedrows); - } else { //Execute the query - $count = count_records_sql("select count(*) $sqlfrom $sqlwhere"); - } + } + $count = count_records_sql("select count(*) $sqlfrom $sqlwhere"); $sqllimit = ''; @@ -265,10 +224,5 @@ } } - //If there are calculatedrows, use them - if (!empty ($calculatedrows)) { - $allentries = $calculatedrows; - } else { //Execute the query - $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit"); - } + $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit"); ?>