1 | <?php |
||
18 | class Quoter implements QuoterInterface |
||
19 | { |
||
20 | /** |
||
21 | * |
||
22 | * The prefix to use when quoting identifier names. |
||
23 | * |
||
24 | * @var string |
||
25 | * |
||
26 | */ |
||
27 | protected $quote_name_prefix = '"'; |
||
28 | |||
29 | /** |
||
30 | * |
||
31 | * The suffix to use when quoting identifier names. |
||
32 | * |
||
33 | * @var string |
||
34 | * |
||
35 | */ |
||
36 | protected $quote_name_suffix = '"'; |
||
37 | |||
38 | /** |
||
39 | * |
||
40 | * Returns the prefix to use when quoting identifier names. |
||
41 | * |
||
42 | * @return string |
||
43 | * |
||
44 | */ |
||
45 | 257 | public function getQuoteNamePrefix() |
|
49 | |||
50 | /** |
||
51 | * |
||
52 | * Returns the suffix to use when quoting identifier names. |
||
53 | * |
||
54 | * @return string |
||
55 | * |
||
56 | */ |
||
57 | 257 | public function getQuoteNameSuffix() |
|
61 | |||
62 | /** |
||
63 | * |
||
64 | * Quotes a single identifier name (table, table alias, table column, |
||
65 | * index, sequence). |
||
66 | * |
||
67 | * If the name contains `' AS '`, this method will separately quote the |
||
68 | * parts before and after the `' AS '`. |
||
69 | * |
||
70 | * If the name contains a space, this method will separately quote the |
||
71 | * parts before and after the space. |
||
72 | * |
||
73 | * If the name contains a dot, this method will separately quote the |
||
74 | * parts before and after the dot. |
||
75 | * |
||
76 | * @param string $spec The identifier name to quote. |
||
77 | * |
||
78 | * @return string The quoted identifier name. |
||
79 | * |
||
80 | * @see replaceName() |
||
81 | * |
||
82 | * @see quoteNameWithSeparator() |
||
83 | * |
||
84 | */ |
||
85 | 243 | public function quoteName($spec) |
|
97 | |||
98 | /** |
||
99 | * |
||
100 | * Quotes an identifier that has a separator. |
||
101 | * |
||
102 | * @param string $spec The identifier name to quote. |
||
103 | * |
||
104 | * @param string $sep The separator, typically a dot or space. |
||
105 | * |
||
106 | * @param int $pos The position of the separator. |
||
107 | * |
||
108 | * @return string The quoted identifier name. |
||
109 | * |
||
110 | */ |
||
111 | 31 | protected function quoteNameWithSeparator($spec, $sep, $pos) |
|
118 | |||
119 | /** |
||
120 | * |
||
121 | * Quotes all fully-qualified identifier names ("table.col") in a string, |
||
122 | * typically an SQL snippet for a SELECT clause. |
||
123 | * |
||
124 | * Does not quote identifier names that are string literals (i.e., inside |
||
125 | * single or double quotes). |
||
126 | * |
||
127 | * Looks for a trailing ' AS alias' and quotes the alias as well. |
||
128 | * |
||
129 | * @param string $text The string in which to quote fully-qualified |
||
130 | * identifier names to quote. |
||
131 | * |
||
132 | * @return string|array The string with names quoted in it. |
||
133 | * |
||
134 | * @see replaceNamesIn() |
||
135 | * |
||
136 | */ |
||
137 | 244 | public function quoteNamesIn($text) |
|
153 | |||
154 | /** |
||
155 | * |
||
156 | * Returns a list of candidate elements for quoting. |
||
157 | * |
||
158 | * @param string $text The text to split into quoting candidates. |
||
159 | * |
||
160 | * @return array |
||
161 | * |
||
162 | */ |
||
163 | 244 | protected function getListForQuoteNamesIn($text) |
|
176 | |||
177 | /** |
||
178 | * |
||
179 | * The in-loop functionality for quoting identifier names. |
||
180 | * |
||
181 | * @param string $val The name to be quoted. |
||
182 | * |
||
183 | * @param bool $is_last Is this the last loop? |
||
184 | * |
||
185 | * @return string The quoted name. |
||
186 | * |
||
187 | */ |
||
188 | 244 | protected function quoteNamesInLoop($val, $is_last) |
|
195 | |||
196 | /** |
||
197 | * |
||
198 | * Replaces the names and alias in a string. |
||
199 | * |
||
200 | * @param string $val The name to be quoted. |
||
201 | * |
||
202 | * @return string The quoted name. |
||
203 | * |
||
204 | */ |
||
205 | 244 | protected function replaceNamesAndAliasIn($val) |
|
215 | |||
216 | /** |
||
217 | * |
||
218 | * Quotes an identifier name (table, index, etc); ignores empty values and |
||
219 | * values of '*'. |
||
220 | * |
||
221 | * @param string $name The identifier name to quote. |
||
222 | * |
||
223 | * @return string The quoted identifier name. |
||
224 | * |
||
225 | * @see quoteName() |
||
226 | * |
||
227 | */ |
||
228 | 254 | protected function replaceName($name) |
|
239 | |||
240 | /** |
||
241 | * |
||
242 | * Quotes all fully-qualified identifier names ("table.col") in a string. |
||
243 | * |
||
244 | * @param string $text The string in which to quote fully-qualified |
||
245 | * identifier names to quote. |
||
246 | * |
||
247 | * @return string|array The string with names quoted in it. |
||
248 | * |
||
249 | * @see quoteNamesIn() |
||
250 | * |
||
251 | */ |
||
252 | 244 | protected function replaceNamesIn($text) |
|
279 | |||
280 | } |
||
281 |