3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Db\Adapter\Platform
;
12 class IbmDb2
extends AbstractPlatform
17 protected $identifierSeparator = '.';
20 * @param array $options
22 public function __construct($options = array())
24 if (isset($options['quote_identifiers'])
25 && ($options['quote_identifiers'] == false
26 ||
$options['quote_identifiers'] === 'false')
28 $this->quoteIdentifiers
= false;
31 if (isset($options['identifier_separator'])) {
32 $this->identifierSeparator
= $options['identifier_separator'];
39 public function getName()
47 public function quoteIdentifierChain($identifierChain)
49 if ($this->quoteIdentifiers
=== false) {
50 return (is_array($identifierChain)) ?
implode($this->identifierSeparator
, $identifierChain) : $identifierChain;
52 $identifierChain = str_replace('"', '\\"', $identifierChain);
53 if (is_array($identifierChain)) {
54 $identifierChain = implode('"' . $this->identifierSeparator
. '"', $identifierChain);
56 return '"' . $identifierChain . '"';
62 public function quoteValue($value)
64 if (function_exists('db2_escape_string')) {
65 return '\'' . db2_escape_string($value) . '\'';
68 'Attempting to quote a value in ' . __CLASS__
. ' without extension/driver support '
69 . 'can introduce security vulnerabilities in a production environment.'
71 return '\'' . str_replace("'", "''", $value) . '\'';
77 public function quoteTrustedValue($value)
79 if (function_exists('db2_escape_string')) {
80 return '\'' . db2_escape_string($value) . '\'';
82 return '\'' . str_replace("'", "''", $value) . '\'';
88 public function getIdentifierSeparator()
90 return $this->identifierSeparator
;