Skip to content

Commit 165e702

Browse files
authored
Merge pull request #105 from alpha0010/master
Remove quoteIdentifier() since it is a no-op as of 5955432
2 parents 52700df + b758f6f commit 165e702

File tree

5 files changed

+24
-83
lines changed

5 files changed

+24
-83
lines changed

src/Drivers/ConnectionBase.php

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -84,40 +84,6 @@ public function getConnection()
8484
throw new ConnectionException('The connection to the server has not been established yet.');
8585
}
8686

87-
/**
88-
* Wraps the input with identifiers when necessary.
89-
*
90-
* @param Expression|string $value The string to be quoted, or an Expression to leave it untouched
91-
*
92-
* @return Expression|string The untouched Expression or the quoted string
93-
*/
94-
public function quoteIdentifier($value)
95-
{
96-
if ($value instanceof Expression) {
97-
return $value->value();
98-
}
99-
100-
return $value;
101-
}
102-
103-
/**
104-
* Calls $this->quoteIdentifier() on every element of the array passed.
105-
*
106-
* @param array $array An array of strings to be quoted
107-
*
108-
* @return array The array of quoted strings
109-
*/
110-
public function quoteIdentifierArr(Array $array = array())
111-
{
112-
$result = array();
113-
114-
foreach ($array as $key => $item) {
115-
$result[$key] = $this->quoteIdentifier($item);
116-
}
117-
118-
return $result;
119-
}
120-
12187
/**
12288
* Adds quotes around values when necessary.
12389
* Based on FuelPHP's quoting function.

src/Drivers/ConnectionInterface.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,6 @@ public function multiQuery(Array $queue);
4444
*/
4545
public function escape($value);
4646

47-
/**
48-
* Wraps the input with identifiers when necessary.
49-
*
50-
* @param Expression|string $value The string to be quoted, or an Expression to leave it untouched
51-
*
52-
* @return Expression|string The untouched Expression or the quoted string
53-
*/
54-
public function quoteIdentifier($value);
55-
56-
/**
57-
* Calls $this->quoteIdentifier() on every element of the array passed.
58-
*
59-
* @param array $array An array of strings to be quoted
60-
*
61-
* @return array The array of quoted strings
62-
*/
63-
public function quoteIdentifierArr(Array $array = array());
64-
6547
/**
6648
* Adds quotes around values when necessary.
6749
*

src/Facet.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ public function compileFacet()
274274
if ($array instanceof Expression) {
275275
$facets[] = $array;
276276
} else if ($array[1] === null) {
277-
$facets[] = $this->getConnection()->quoteIdentifier($array[0]);
277+
$facets[] = $array[0];
278278
} else {
279-
$facets[] = $this->getConnection()->quoteIdentifier($array[0]).' AS '.$array[1];
279+
$facets[] = $array[0].' AS '.$array[1];
280280
}
281281
}
282282
$query .= implode(', ', $facets).' ';
@@ -285,7 +285,7 @@ public function compileFacet()
285285
}
286286

287287
if (!empty($this->by)) {
288-
$query .= 'BY '.$this->getConnection()->quoteIdentifier($this->by).' ';
288+
$query .= 'BY '.$this->by.' ';
289289
}
290290

291291
if (!empty($this->order_by)) {
@@ -294,7 +294,7 @@ public function compileFacet()
294294
$order_arr = array();
295295

296296
foreach ($this->order_by as $order) {
297-
$order_sub = $this->getConnection()->quoteIdentifier($order['column']).' ';
297+
$order_sub = $order['column'].' ';
298298
$order_sub .= ((strtolower($order['direction']) === 'desc') ? 'DESC' : 'ASC');
299299

300300
$order_arr[] = $order_sub;

src/Helper.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,7 @@ public function setVariable($name, $value, $global = false)
149149

150150
$user_var = strpos($name, '@') === 0;
151151

152-
// if it has an @ it's a user variable and we can't wrap it
153-
if ($user_var) {
154-
$query .= $name.' ';
155-
} else {
156-
$query .= $this->getConnection()->quoteIdentifier($name).' ';
157-
}
152+
$query .= $name.' ';
158153

159154
// user variables must always be processed as arrays
160155
if ($user_var && ! is_array($value)) {
@@ -220,7 +215,7 @@ public function callKeywords($text, $index, $hits = null)
220215
*/
221216
public function describe($index)
222217
{
223-
return $this->query('DESCRIBE '.$this->getConnection()->quoteIdentifier($index));
218+
return $this->query('DESCRIBE '.$index);
224219
}
225220

226221
/**
@@ -234,7 +229,7 @@ public function describe($index)
234229
*/
235230
public function createFunction($udf_name, $returns, $so_name)
236231
{
237-
return $this->query('CREATE FUNCTION '.$this->getConnection()->quoteIdentifier($udf_name).
232+
return $this->query('CREATE FUNCTION '.$udf_name.
238233
' RETURNS '.$returns.' SONAME '.$this->getConnection()->quote($so_name));
239234
}
240235

@@ -247,7 +242,7 @@ public function createFunction($udf_name, $returns, $so_name)
247242
*/
248243
public function dropFunction($udf_name)
249244
{
250-
return $this->query('DROP FUNCTION '.$this->getConnection()->quoteIdentifier($udf_name));
245+
return $this->query('DROP FUNCTION '.$udf_name);
251246
}
252247

253248
/**
@@ -260,8 +255,7 @@ public function dropFunction($udf_name)
260255
*/
261256
public function attachIndex($disk_index, $rt_index)
262257
{
263-
return $this->query('ATTACH INDEX '.$this->getConnection()->quoteIdentifier($disk_index).
264-
' TO RTINDEX '. $this->getConnection()->quoteIdentifier($rt_index));
258+
return $this->query('ATTACH INDEX '.$disk_index.' TO RTINDEX '.$rt_index);
265259
}
266260

267261
/**
@@ -273,7 +267,7 @@ public function attachIndex($disk_index, $rt_index)
273267
*/
274268
public function flushRtIndex($index)
275269
{
276-
return $this->query('FLUSH RTINDEX '.$this->getConnection()->quoteIdentifier($index));
270+
return $this->query('FLUSH RTINDEX '.$index);
277271
}
278272

279273
/**
@@ -285,7 +279,7 @@ public function flushRtIndex($index)
285279
*/
286280
public function optimizeIndex($index)
287281
{
288-
return $this->query('OPTIMIZE INDEX '.$this->getConnection()->quoteIdentifier($index));
282+
return $this->query('OPTIMIZE INDEX '.$index);
289283
}
290284

291285
/**
@@ -297,7 +291,7 @@ public function optimizeIndex($index)
297291
*/
298292
public function showIndexStatus($index)
299293
{
300-
return $this->query('SHOW INDEX '.$this->getConnection()->quoteIdentifier($index).' STATUS');
294+
return $this->query('SHOW INDEX '.$index.' STATUS');
301295
}
302296

303297
/**
@@ -309,6 +303,6 @@ public function showIndexStatus($index)
309303
*/
310304
public function flushRamchunk($index)
311305
{
312-
return $this->query('FLUSH RAMCHUNK '.$this->getConnection()->quoteIdentifier($index));
306+
return $this->query('FLUSH RAMCHUNK '.$index);
313307
}
314308
}

src/SphinxQL.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ public function compileFilterCondition($filter)
502502

503503
if (!empty($filter)) {
504504
if (strtoupper($filter['operator']) === 'BETWEEN') {
505-
$query .= $this->getConnection()->quoteIdentifier($filter['column']);
505+
$query .= $filter['column'];
506506
$query .= ' BETWEEN ';
507507
$query .= $this->getConnection()->quote($filter['value'][0]).' AND '
508508
.$this->getConnection()->quote($filter['value'][1]).' ';
@@ -511,7 +511,7 @@ public function compileFilterCondition($filter)
511511
if ($filter['column'] === 'id') {
512512
$query .= 'id ';
513513
} else {
514-
$query .= $this->getConnection()->quoteIdentifier($filter['column']).' ';
514+
$query .= $filter['column'].' ';
515515
}
516516

517517
if (in_array(strtoupper($filter['operator']), array('IN', 'NOT IN'), true)) {
@@ -538,7 +538,7 @@ public function compileSelect()
538538
$query .= 'SELECT ';
539539

540540
if (!empty($this->select)) {
541-
$query .= implode(', ', $this->getConnection()->quoteIdentifierArr($this->select)).' ';
541+
$query .= implode(', ', $this->select).' ';
542542
} else {
543543
$query .= '* ';
544544
}
@@ -552,14 +552,14 @@ public function compileSelect()
552552
} elseif ($this->from instanceof SphinxQL) {
553553
$query .= 'FROM ('.$this->from->compile()->getCompiled().') ';
554554
} else {
555-
$query .= 'FROM '.implode(', ', $this->getConnection()->quoteIdentifierArr($this->from)).' ';
555+
$query .= 'FROM '.implode(', ', $this->from).' ';
556556
}
557557
}
558558

559559
$query .= $this->compileMatch().$this->compileWhere();
560560

561561
if (!empty($this->group_by)) {
562-
$query .= 'GROUP BY '.implode(', ', $this->getConnection()->quoteIdentifierArr($this->group_by)).' ';
562+
$query .= 'GROUP BY '.implode(', ', $this->group_by).' ';
563563
}
564564

565565
if (!empty($this->within_group_order_by)) {
@@ -568,7 +568,7 @@ public function compileSelect()
568568
$order_arr = array();
569569

570570
foreach ($this->within_group_order_by as $order) {
571-
$order_sub = $this->getConnection()->quoteIdentifier($order['column']).' ';
571+
$order_sub = $order['column'].' ';
572572

573573
if ($order['direction'] !== null) {
574574
$order_sub .= ((strtolower($order['direction']) === 'desc') ? 'DESC' : 'ASC');
@@ -590,7 +590,7 @@ public function compileSelect()
590590
$order_arr = array();
591591

592592
foreach ($this->order_by as $order) {
593-
$order_sub = $this->getConnection()->quoteIdentifier($order['column']).' ';
593+
$order_sub = $order['column'].' ';
594594

595595
if ($order['direction'] !== null) {
596596
$order_sub .= ((strtolower($order['direction']) === 'desc') ? 'DESC' : 'ASC');
@@ -632,8 +632,7 @@ function (&$val, $key) {
632632
$option['value'] = $this->getConnection()->quote($option['value']);
633633
}
634634

635-
$options[] = $this->getConnection()->quoteIdentifier($option['name'])
636-
.' = '.$option['value'];
635+
$options[] = $option['name'].' = '.$option['value'];
637636
}
638637

639638
$query .= 'OPTION '.implode(', ', $options).' ';
@@ -681,7 +680,7 @@ public function compileInsert()
681680
}
682681

683682
if (!empty($this->columns)) {
684-
$query .= '('.implode(', ', $this->getConnection()->quoteIdentifierArr($this->columns)).') ';
683+
$query .= '('.implode(', ', $this->columns).') ';
685684
}
686685

687686
if (!empty($this->values)) {
@@ -722,10 +721,10 @@ public function compileUpdate()
722721
foreach ($this->set as $column => $value) {
723722
// MVA support
724723
if (is_array($value)) {
725-
$query_sub[] = $this->getConnection()->quoteIdentifier($column)
724+
$query_sub[] = $column
726725
.' = ('.implode(', ', $this->getConnection()->quoteArr($value)).')';
727726
} else {
728-
$query_sub[] = $this->getConnection()->quoteIdentifier($column)
727+
$query_sub[] = $column
729728
.' = '.$this->getConnection()->quote($value);
730729
}
731730
}

0 commit comments

Comments
 (0)