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 / Sql92.php
blob681774c4d642fde752fa63c815e8082f0f57a819
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 Sql92 implements PlatformInterface
14 /**
15 * Get name
17 * @return string
19 public function getName()
21 return 'SQL92';
24 /**
25 * Get quote indentifier symbol
27 * @return string
29 public function getQuoteIdentifierSymbol()
31 return '"';
34 /**
35 * Quote identifier
37 * @param string $identifier
38 * @return string
40 public function quoteIdentifier($identifier)
42 return '"' . str_replace('"', '\\' . '"', $identifier) . '"';
45 /**
46 * Quote identifier chain
48 * @param string|string[] $identifierChain
49 * @return string
51 public function quoteIdentifierChain($identifierChain)
53 $identifierChain = str_replace('"', '\\"', $identifierChain);
54 if (is_array($identifierChain)) {
55 $identifierChain = implode('"."', $identifierChain);
57 return '"' . $identifierChain . '"';
60 /**
61 * Get quote value symbol
63 * @return string
65 public function getQuoteValueSymbol()
67 return '\'';
70 /**
71 * Quote value
73 * @param string $value
74 * @return string
76 public function quoteValue($value)
78 trigger_error(
79 'Attempting to quote a value without specific driver level support can introduce security vulnerabilities in a production environment.'
81 return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
84 /**
85 * Quote Trusted Value
87 * The ability to quote values without notices
89 * @param $value
90 * @return mixed
92 public function quoteTrustedValue($value)
94 return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
97 /**
98 * Quote value list
100 * @param string|string[] $valueList
101 * @return string
103 public function quoteValueList($valueList)
105 if (!is_array($valueList)) {
106 return $this->quoteValue($valueList);
109 $value = reset($valueList);
110 do {
111 $valueList[key($valueList)] = $this->quoteValue($value);
112 } while ($value = next($valueList));
113 return implode(', ', $valueList);
117 * Get identifier separator
119 * @return string
121 public function getIdentifierSeparator()
123 return '.';
127 * Quote identifier in fragment
129 * @param string $identifier
130 * @param array $safeWords
131 * @return string
133 public function quoteIdentifierInFragment($identifier, array $safeWords = array())
135 $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
136 if ($safeWords) {
137 $safeWords = array_flip($safeWords);
138 $safeWords = array_change_key_case($safeWords, CASE_LOWER);
140 foreach ($parts as $i => $part) {
141 if ($safeWords && isset($safeWords[strtolower($part)])) {
142 continue;
145 switch ($part) {
146 case ' ':
147 case '.':
148 case '*':
149 case 'AS':
150 case 'As':
151 case 'aS':
152 case 'as':
153 break;
154 default:
155 $parts[$i] = '"' . str_replace('"', '\\' . '"', $part) . '"';
159 return implode('', $parts);