From 8351e29517541858a914a518322dac0f4040c3e4 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Fri, 1 Sep 2006 17:45:02 +0000 Subject: [PATCH] Introduced one function to calculate the proper "AS" keyword for columns. All DB seems to support it but PostgreSQL require it! --- lib/dmllib.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/dmllib.php b/lib/dmllib.php index ef350fd4af..24324d56d3 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -1247,6 +1247,8 @@ function sql_fullname($firstname='firstname', $lastname='lastname') { return ' CONCAT('. $firstname .'," ",'. $lastname .') '; case 'postgres7': return " ". $firstname ."||' '||". $lastname ." "; + case 'mssql': + return " ". $firstname ."+' '+". $lastname ." "; default: return ' '. $firstname .'||" "||'. $lastname .' '; } @@ -1269,6 +1271,27 @@ function sql_isnull($fieldname) { } } +/** + * Returns the proper AS keyword to be used to aliase columns + * SQL defines the keyword as optional and nobody but PG + * seems to require it. This function should be used inside all + * the statements using column aliases. + * Note than the use of table aliases doesn't require the + * AS keyword at all, only columns for postgres. + * @uses $CFG + * @ return string the keyword + */ +function sql_as() { + global $db; + + switch ($CFG->dbtype) { + case 'postgres7': + return 'AS'; + default: + return ''; + } +} + /** * Prepare a SQL WHERE clause to select records where the given fields match the given values. * @@ -1321,6 +1344,7 @@ function column_type($table, $column) { return $rs->MetaType($field->type); } + /** * This function, called from setup.php includes all the configuration * needed to properly work agains any DB. It setups connection encoding -- 2.39.5