public function testQuoteStringLiteral()
 {
     $c = $this->getStringLiteralQuoteCharacter();
     $this->assertEquals($this->getQuotedStringLiteralWithoutQuoteCharacter(), $this->_platform->quoteStringLiteral('No quote'));
     $this->assertEquals($this->getQuotedStringLiteralWithQuoteCharacter(), $this->_platform->quoteStringLiteral('It' . $c . 's a quote'));
     $this->assertEquals($this->getQuotedStringLiteralQuoteCharacter(), $this->_platform->quoteStringLiteral($c));
 }
 /**
  * @param array            $fieldDeclaration
  * @param AbstractPlatform $platform
  *
  * @throws DBALException
  *
  * @return string
  */
 public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
 {
     $values = array();
     foreach ($this->getValues($fieldDeclaration) as $value) {
         $values[] = $platform->quoteStringLiteral($value);
     }
     if ($platform instanceof MySqlPlatform) {
         return 'ENUM(' . implode(',', $values) . ')';
     }
     return $platform->getBigIntTypeDeclarationSQL($fieldDeclaration);
 }
 /**
  * @param array            $fieldDeclaration
  * @param AbstractPlatform $platform
  *
  * @throws DBALException
  *
  * @return string
  */
 public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
 {
     if ($platform instanceof DB2Platform or $platform instanceof OraclePlatform or $platform instanceof SqlitePlatform or $platform instanceof SQLServerPlatform) {
         throw new DBALException('ENUMs are not supported by ' . $platform->getName() . '.');
     }
     if (!empty($fieldDeclaration['values']) && is_array($fieldDeclaration['values'])) {
         $values = array();
         foreach ($fieldDeclaration['values'] as $value) {
             $values[] = $platform->quoteStringLiteral($value);
         }
         return 'ENUM (' . implode(',', $values) . ')';
     }
 }
Exemple #4
0
 /**
  * {@inheritdoc}
  */
 public function quoteStringLiteral($str)
 {
     $str = str_replace('\\', '\\\\', $str);
     // MySQL requires backslashes to be escaped aswell.
     return parent::quoteStringLiteral($str);
 }