Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions library/Zend/Db/Adapter/Platform/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getQuoteIdentifierSymbol()
*/
public function quoteIdentifier($identifier)
{
return '`' . str_replace('`', '\\' . '`', $identifier) . '`';
return '`' . str_replace('`', '``', $identifier) . '`';
}

/**
Expand All @@ -57,7 +57,7 @@ public function quoteIdentifier($identifier)
*/
public function quoteIdentifierChain($identifierChain)
{
$identifierChain = str_replace('`', '\\`', $identifierChain);
$identifierChain = str_replace('`', '``', $identifierChain);
if (is_array($identifierChain)) {
$identifierChain = implode('`.`', $identifierChain);
}
Expand Down Expand Up @@ -134,7 +134,7 @@ public function quoteIdentifierInFragment($identifier, array $safeWords = array(
case 'as':
break;
default:
$parts[$i] = '`' . str_replace('`', '\\' . '`', $part) . '`';
$parts[$i] = '`' . str_replace('`', '``', $part) . '`';
}
}
return implode('', $parts);
Expand Down
7 changes: 6 additions & 1 deletion tests/ZendTest/Db/Adapter/Platform/MysqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public function testGetQuoteIdentifierSymbol()
public function testQuoteIdentifier()
{
$this->assertEquals('`identifier`', $this->platform->quoteIdentifier('identifier'));
$this->assertEquals('`ident``ifier`', $this->platform->quoteIdentifier('ident`ifier'));
}

/**
* @covers Zend\Db\Adapter\Platform\Mysql::quoteIdentifierChain
*/
Expand All @@ -60,6 +61,10 @@ public function testQuoteIdentifierChain()
$this->assertEquals('`identifier`', $this->platform->quoteIdentifierChain('identifier'));
$this->assertEquals('`identifier`', $this->platform->quoteIdentifierChain(array('identifier')));
$this->assertEquals('`schema`.`identifier`', $this->platform->quoteIdentifierChain(array('schema','identifier')));

$this->assertEquals('`ident``ifier`', $this->platform->quoteIdentifierChain('ident`ifier'));
$this->assertEquals('`ident``ifier`', $this->platform->quoteIdentifierChain(array('ident`ifier')));
$this->assertEquals('`schema`.`ident``ifier`', $this->platform->quoteIdentifierChain(array('schema','ident`ifier')));
}

/**
Expand Down