From c9128b637b7902721db55d5510eeddf9ef105767 Mon Sep 17 00:00:00 2001 From: willcast Date: Sat, 21 Feb 2004 13:21:35 +0000 Subject: [PATCH] - Dealing with incompatibilities related to posgresql. --- mod/glossary/dynalink.php | 12 ++++++++++-- mod/glossary/sql.php | 21 +++++++++++++++------ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/mod/glossary/dynalink.php b/mod/glossary/dynalink.php index b337e4c130..f078d0fcc8 100644 --- a/mod/glossary/dynalink.php +++ b/mod/glossary/dynalink.php @@ -11,6 +11,14 @@ $GLOSSARY_CONCEPT_IS_ENTRY = 0; $GLOSSARY_CONCEPT_IS_CATEGORY = 1; + switch ($CFG->dbtype) { + case 'postgres7': + $as = 'as'; + break; + case 'mysql': + $as = ''; + break; + } $glossarieslist = get_records_select("glossary", "usedynalink != 0 and (course = $courseid or globalglossary != 0)","globalglossary, id"); if ( $glossarieslist ) { @@ -33,8 +41,8 @@ break; } - $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0 and concept != ''","$ebylenght glossaryid","id,glossaryid, concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch"); - $categories = get_records_select("glossary_categories", "glossaryid IN ($glossaries) AND usedynalink != 0", "$cbylenght glossaryid","id,glossaryid, name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch"); + $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0 and concept != ''","$ebylenght glossaryid","id,glossaryid, concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY $as category,fullmatch"); + $categories = get_records_select("glossary_categories", "glossaryid IN ($glossaries) AND usedynalink != 0", "$cbylenght glossaryid","id,glossaryid, name $as concept, 1 $as casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY $as category, 1 $as fullmatch"); if ( $entries and $categories ) { $concepts = array_merge($entries, $categories); usort($concepts,'glossary_sort_entries_by_lenght'); diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php index bd3ed71fbc..9b818c8f7a 100644 --- a/mod/glossary/sql.php +++ b/mod/glossary/sql.php @@ -13,6 +13,15 @@ /// fullpivot indicate if the whole pivot should be compared agasint the db or just the first letter /// printpivot indicate if the pivot should be printed or not + switch ($CFG->dbtype) { + case 'postgres7': + $as = 'as'; + break; + case 'mysql': + $as = ''; + break; + } + switch ( $sortkey ) { case "CREATION": $sqlsortkey = "timecreated"; @@ -34,7 +43,7 @@ case GLOSSARY_CATEGORY_VIEW: if ($hook == GLOSSARY_SHOW_ALL_CATEGORIES ) { - $sqlselect = "SELECT gec.id, gc.name pivot, ge.*"; + $sqlselect = "SELECT gec.id, gc.name $as pivot, ge.*"; $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories gec, {$CFG->prefix}glossary_categories gc"; @@ -51,7 +60,7 @@ } elseif ($hook == GLOSSARY_SHOW_NOT_CATEGORISED ) { $printpivot = 0; - $sqlselect = "SELECT concept pivot, ge.*"; + $sqlselect = "SELECT concept $as pivot, ge.*"; $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge"; $sqlwhere = "WHERE (glossaryid = '$glossary->id' OR sourceglossaryid = '$glossary->id') AND (ge.approved != 0 $userid)"; @@ -62,7 +71,7 @@ } else { $printpivot = 0; - $sqlselect = "SELECT ce.id, c.name pivot, ge.*"; + $sqlselect = "SELECT ce.id, c.name $as pivot, ge.*"; $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories ce, {$CFG->prefix}glossary_categories c"; $sqlwhere = "WHERE ge.id = ce.entryid AND ce.categoryid = $hook AND ce.categoryid = c.id AND ge.approved != 0 AND @@ -99,7 +108,7 @@ $where = ''; } - $sqlselect = "SELECT ge.id, $usernamefield pivot, u.id uid, ge.*"; + $sqlselect = "SELECT ge.id, $usernamefield $as pivot, u.id uid, ge.*"; $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}user u"; $sqlwhere = "WHERE ge.userid = u.id AND (ge.approved != 0 $userid) @@ -123,7 +132,7 @@ } } - $sqlselect = "SELECT ge.concept pivot, ge.*"; + $sqlselect = "SELECT ge.concept $as pivot, ge.*"; $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge"; $sqlwhere = "WHERE (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id) AND ge.approved = 0 $where"; @@ -137,7 +146,7 @@ case GLOSSARY_DATE_VIEW: case GLOSSARY_STANDARD_VIEW: default: - $sqlselect = "SELECT ge.concept pivot, ge.*"; + $sqlselect = "SELECT ge.concept $as pivot, ge.*"; $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge"; $where = ''; -- 2.39.5