From a5e48d968d0f5032a748f9cabe138d1f9dd86c7f Mon Sep 17 00:00:00 2001 From: willcast Date: Sat, 21 Feb 2004 13:05:38 +0000 Subject: [PATCH] - Fixing come incompatilities with PostgreSQL. THANKS TO ULRIK PETERSON! --- mod/glossary/lib.php | 10 +++++++--- mod/glossary/sql.php | 11 ++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 3c2d3f5951..520f865cb5 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -729,17 +729,21 @@ function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL) } /// Some differences in syntax for entrygreSQL - if ($CFG->dbtype == "entrygres7") { + switch ($CFG->dbtype) { + case 'postgres7': $LIKE = "ILIKE"; // case-insensitive $NOTLIKE = "NOT ILIKE"; // case-insensitive $REGEXP = "~*"; $NOTREGEXP = "!~*"; - } else { + break; + case 'mysql': + default: $LIKE = "LIKE"; $NOTLIKE = "NOT LIKE"; $REGEXP = "REGEXP"; $NOTREGEXP = "NOT REGEXP"; - } + break; + } $conceptsearch = ""; $definitionsearch = ""; diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php index 46b90b67ac..bd3ed71fbc 100644 --- a/mod/glossary/sql.php +++ b/mod/glossary/sql.php @@ -203,9 +203,18 @@ } $count = count_records_sql("select count(*) $sqlfrom $sqlwhere"); $sqllimit = ''; + if ( $offset >= 0 ) { - $sqllimit = " LIMIT $offset, $entriesbypage"; + switch ($CFG->dbtype) { + case 'postgres7': + $sqllimit = " LIMIT $entriesbypage OFFSET $offset"; + break; + case 'mysql': + $sqllimit = " LIMIT $offset, $entriesbypage"; + break; + } } + $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit"); ?> \ No newline at end of file -- 2.39.5