]> git.mjollnir.org Git - moodle.git/commitdiff
- Dealing with incompatibilities related to posgresql.
authorwillcast <willcast>
Sat, 21 Feb 2004 13:21:35 +0000 (13:21 +0000)
committerwillcast <willcast>
Sat, 21 Feb 2004 13:21:35 +0000 (13:21 +0000)
mod/glossary/dynalink.php
mod/glossary/sql.php

index b337e4c130f13f446e6a1a4d0763fb0b62429a37..f078d0fcc8a848becb0844cfd27c2c14dc9a670e 100644 (file)
 
         $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');
index bd3ed71fbc6d238ea99984c020a558a2863c89d2..9b818c8f7a4c0d9e379d5a16d4b8522ef73c130b 100644 (file)
 
 /// 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
             $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)
             }
         }
 
-        $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";
     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 = '';