diff --git a/src/Adapter/Platform/AbstractPlatform.php b/src/Adapter/Platform/AbstractPlatform.php index 1857c7ba92..48c9a97cb0 100644 --- a/src/Adapter/Platform/AbstractPlatform.php +++ b/src/Adapter/Platform/AbstractPlatform.php @@ -1,10 +1,8 @@ quoteIdentifiers) { - return $identifier; - } - - return $this->quoteIdentifier[0] - . str_replace($this->quoteIdentifier[0], $this->quoteIdentifierTo, $identifier) - . $this->quoteIdentifier[1]; + return $this->quoteIdentifierChain([$identifier]); } /** @@ -80,7 +72,21 @@ public function quoteIdentifier($identifier) */ public function quoteIdentifierChain($identifierChain) { - return '"' . implode('"."', (array) str_replace('"', '\\"', $identifierChain)) . '"'; + if (is_string($identifierChain)) { + $identifierChain = [$identifierChain]; + } + + if (! $this->quoteIdentifiers) { + return implode($this->getIdentifierSeparator(), $identifierChain); + } + + /** @var array $identifierChain */ + foreach ($identifierChain as $key => $identifier) { + $identifierChain[$key] = str_replace($this->quoteIdentifier[0], $this->quoteIdentifierTo, $identifier); + } + $chainGlue = $this->quoteIdentifier[1] . $this->getIdentifierSeparator() . $this->quoteIdentifier[0]; + + return $this->quoteIdentifier[0] . implode($chainGlue, $identifierChain) . $this->quoteIdentifier[1]; } /** @@ -105,8 +111,11 @@ public function getQuoteValueSymbol() public function quoteValue($value) { trigger_error( - 'Attempting to quote a value in ' . get_class($this) . - ' without extension/driver support can introduce security vulnerabilities in a production environment' + sprintf( + 'Attempting to quote a value in %s without extension/driver support ' . + 'can introduce security vulnerabilities in a production environment', + get_class($this) + ) ); return '\'' . addcslashes((string) $value, "\x00\n\r\\'\"\x1a") . '\''; } diff --git a/src/Adapter/Platform/Mysql.php b/src/Adapter/Platform/Mysql.php index f239fd0e4f..41b63fd3fa 100644 --- a/src/Adapter/Platform/Mysql.php +++ b/src/Adapter/Platform/Mysql.php @@ -1,10 +1,8 @@ quoteIdentifiers === false) { - return implode('.', (array) $identifierChain); - } - - return '"' . implode('"."', (array) str_replace('"', '\\"', $identifierChain)) . '"'; - } - /** * {@inheritDoc} */ diff --git a/src/Adapter/Platform/Postgresql.php b/src/Adapter/Platform/Postgresql.php index 8763f4aef7..36ff21a325 100644 --- a/src/Adapter/Platform/Postgresql.php +++ b/src/Adapter/Platform/Postgresql.php @@ -1,10 +1,8 @@ quoteIdentifier; } - /** - * {@inheritDoc} - */ - public function quoteIdentifierChain($identifierChain) - { - return '[' . implode('].[', (array) $identifierChain) . ']'; - } - /** * {@inheritDoc} */ diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index f7d1d42e82..b945a1fb9e 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -1,10 +1,8 @@ quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table; + $table = $platform->quoteIdentifierChain($schema) . $platform->getIdentifierSeparator() . $table; } return $table; }