Skip to content

Commit 91e28ab

Browse files
committed
Switch order of method definitions: matchNamedBinds() below matchSimpleBinds()
To correspond to the new code structure in compileBinds(), and because named binds are arguably more advanced than simple binds.
1 parent d2518b9 commit 91e28ab

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

system/Database/Query.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -302,30 +302,6 @@ protected function compileBinds()
302302
}
303303
}
304304

305-
/**
306-
* Match bindings
307-
*/
308-
protected function matchNamedBinds(string $sql, array $binds): string
309-
{
310-
$replacers = [];
311-
312-
foreach ($binds as $placeholder => $value) {
313-
// $value[1] contains the boolean whether should be escaped or not
314-
$escapedValue = $value[1] ? $this->db->escape($value[0]) : $value[0];
315-
316-
// In order to correctly handle backlashes in saved strings
317-
// we will need to preg_quote, so remove the wrapping escape characters
318-
// otherwise it will get escaped.
319-
if (is_array($value[0])) {
320-
$escapedValue = '(' . implode(',', $escapedValue) . ')';
321-
}
322-
323-
$replacers[":{$placeholder}:"] = $escapedValue;
324-
}
325-
326-
return strtr($sql, $replacers);
327-
}
328-
329305
/**
330306
* Match bindings
331307
*/
@@ -356,6 +332,30 @@ protected function matchSimpleBinds(string $sql, array $binds, int $bindCount, i
356332
return $sql;
357333
}
358334

335+
/**
336+
* Match bindings
337+
*/
338+
protected function matchNamedBinds(string $sql, array $binds): string
339+
{
340+
$replacers = [];
341+
342+
foreach ($binds as $placeholder => $value) {
343+
// $value[1] contains the boolean whether should be escaped or not
344+
$escapedValue = $value[1] ? $this->db->escape($value[0]) : $value[0];
345+
346+
// In order to correctly handle backlashes in saved strings
347+
// we will need to preg_quote, so remove the wrapping escape characters
348+
// otherwise it will get escaped.
349+
if (is_array($value[0])) {
350+
$escapedValue = '(' . implode(',', $escapedValue) . ')';
351+
}
352+
353+
$replacers[":{$placeholder}:"] = $escapedValue;
354+
}
355+
356+
return strtr($sql, $replacers);
357+
}
358+
359359
/**
360360
* Returns string to display in debug toolbar
361361
*/

0 commit comments

Comments
 (0)