Skip to content

Commit

Permalink
Handle already quoted identifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Dec 27, 2017
1 parent f2b7c43 commit 541a8ca
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Resources/contao/library/Contao/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class Database
*/
protected static $arrInstances = array();

/**
* Quote character
* @var string
*/
protected static $strQuoteCharacter;

/**
* Connection ID
* @var Connection
Expand Down Expand Up @@ -715,6 +721,17 @@ public function getUuid()
*/
public static function quoteColumnName($strName)
{
if (static::$strQuoteCharacter === null)
{
static::$strQuoteCharacter = \System::getContainer()->get('database_connection')->getDatabasePlatform()->getIdentifierQuoteCharacter();
}

// The identifier is quoted already
if (strncmp($strName, static::$strQuoteCharacter, 1) === 0 && substr_compare($strName, static::$strQuoteCharacter, -1) === 0)

This comment has been minimized.

Copy link
@leofeyer

leofeyer Jan 18, 2018

Author Member

We only need to check the first character here, so we can omit substr_compare().

{
return $strName;
}

return \System::getContainer()->get('database_connection')->quoteIdentifier($strName);
}

Expand Down

0 comments on commit 541a8ca

Please sign in to comment.