Procházet zdrojové kódy

fixed pgsql identifierQuote in PDO

Piotr Labudda před 7 roky
rodič
revize
8e7977d099
1 změnil soubory, kde provedl 9 přidání a 1 odebrání
  1. 9 1
      SE/se-lib/Core/Pdo.php

+ 9 - 1
SE/se-lib/Core/Pdo.php

@@ -38,11 +38,19 @@ class Core_Pdo extends PDO {
 	public function identifierQuote($identifier) {
 		switch (strtolower($this->_type)) {
 			// case 'pgsql': return $identifier;
-			case 'pgsql': return "\"{$identifier}\""; // https://www.postgresql.org/docs/9.1/sql-syntax-lexical.html
+			case 'pgsql': return $this->pgsqlIdentifierQuote($identifier);
 			case 'mysql': return "`{$identifier}`";
 		}
 		return $identifier;
 	}
+	function pgsqlIdentifierQuote($identifier) {
+		if (false !== strpos($identifier, '.')) {
+			return implode('.', array_map(function ($token) {
+				return "\"{$token}\"";
+			}, explode('.', $identifier)));
+		}
+		return "\"{$identifier}\""; // https://www.postgresql.org/docs/9.1/sql-syntax-lexical.html
+	}
 
 	public function tableNameQuote($tableName) {
 		switch (strtolower($this->_type)) {