Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Db / Adapter / Platform / Oracle.php
blob9081243d3f6752afff409258958282053026f8e3
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Db\Adapter\Platform;
12 class Oracle implements PlatformInterface
15 /**
16 * @var bool
18 protected $quoteIdentifiers = true;
20 /**
21 * @param array $options
23 public function __construct($options = array())
25 if (isset($options['quote_identifiers'])
26 && ($options['quote_identifiers'] == false
27 || $options['quote_identifiers'] === 'false')
28 ) {
29 $this->quoteIdentifiers = false;
33 /**
34 * Get name
36 * @return string
38 public function getName()
40 return 'Oracle';
43 /**
44 * Get quote identifier symbol
46 * @return string
48 public function getQuoteIdentifierSymbol()
50 return '"';
53 /**
54 * Quote identifier
56 * @param string $identifier
57 * @return string
59 public function quoteIdentifier($identifier)
61 if ($this->quoteIdentifiers === false) {
62 return $identifier;
64 return '"' . str_replace('"', '\\' . '"', $identifier) . '"';
67 /**
68 * Quote identifier chain
70 * @param string|string[] $identifierChain
71 * @return string
73 public function quoteIdentifierChain($identifierChain)
75 if ($this->quoteIdentifiers === false) {
76 return (is_array($identifierChain)) ? implode('.', $identifierChain) : $identifierChain;
78 $identifierChain = str_replace('"', '\\"', $identifierChain);
79 if (is_array($identifierChain)) {
80 $identifierChain = implode('"."', $identifierChain);
82 return '"' . $identifierChain . '"';
85 /**
86 * Get quote value symbol
88 * @return string
90 public function getQuoteValueSymbol()
92 return '\'';
95 /**
96 * Quote value
98 * @param string $value
99 * @return string
101 public function quoteValue($value)
103 trigger_error(
104 'Attempting to quote a value in ' . __CLASS__ . ' without extension/driver support '
105 . 'can introduce security vulnerabilities in a production environment.'
107 return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
111 * Quote Trusted Value
113 * The ability to quote values without notices
115 * @param $value
116 * @return mixed
118 public function quoteTrustedValue($value)
120 return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
124 * Quote value list
126 * @param string|string[] $valueList
127 * @return string
129 public function quoteValueList($valueList)
131 if (!is_array($valueList)) {
132 return $this->quoteValue($valueList);
135 $value = reset($valueList);
136 do {
137 $valueList[key($valueList)] = $this->quoteValue($value);
138 } while ($value = next($valueList));
139 return implode(', ', $valueList);
143 * Get identifier separator
145 * @return string
147 public function getIdentifierSeparator()
149 return '.';
153 * Quote identifier in fragment
155 * @param string $identifier
156 * @param array $safeWords
157 * @return string
159 public function quoteIdentifierInFragment($identifier, array $safeWords = array())
161 if ($this->quoteIdentifiers === false) {
162 return $identifier;
164 $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
165 if ($safeWords) {
166 $safeWords = array_flip($safeWords);
167 $safeWords = array_change_key_case($safeWords, CASE_LOWER);
169 foreach ($parts as $i => $part) {
170 if ($safeWords && isset($safeWords[strtolower($part)])) {
171 continue;
173 switch ($part) {
174 case ' ':
175 case '.':
176 case '*':
177 case 'AS':
178 case 'As':
179 case 'aS':
180 case 'as':
181 break;
182 default:
183 $parts[$i] = '"' . str_replace('"', '\\' . '"', $part) . '"';
186 return implode('', $parts);