Skip to content

Commit b5de102

Browse files
committed
Determine if binds are simple or named by looking at the $binds array
1 parent c05f5a6 commit b5de102

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

system/Database/Query.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,7 @@ protected function compileBinds()
275275
{
276276
$sql = $this->finalQueryString;
277277

278-
$hasBinds = strpos($sql, $this->bindMarker) !== false;
279-
$hasNamedBinds = ! $hasBinds
280-
&& preg_match('/:(?!=).+:/', $sql) === 1;
281-
282-
if (empty($this->binds)
283-
|| empty($this->bindMarker)
284-
|| (! $hasNamedBinds && ! $hasBinds)
285-
) {
278+
if (empty($this->binds)) {
286279
return;
287280
}
288281

@@ -294,16 +287,25 @@ protected function compileBinds()
294287
$bindCount = count($binds);
295288
}
296289

297-
// Reverse the binds so that duplicate named binds
298-
// will be processed prior to the original binds.
299-
if (! is_numeric(key(array_slice($binds, 0, 1)))) {
300-
$binds = array_reverse($binds);
301-
}
290+
if (is_numeric(key(array_slice($binds, 0, 1)))) {
291+
if (empty($this->bindMarker) || strpos($sql, $this->bindMarker) === false) {
292+
return;
293+
}
302294

303-
$ml = strlen($this->bindMarker);
304-
$sql = $hasNamedBinds ? $this->matchNamedBinds($sql, $binds) : $this->matchSimpleBinds($sql, $binds, $bindCount, $ml);
295+
$ml = strlen($this->bindMarker);
305296

306-
$this->finalQueryString = $sql;
297+
$this->finalQueryString = $this->matchSimpleBinds($sql, $binds, $bindCount, $ml);
298+
} else {
299+
if (! preg_match('/:(?!=).+:/', $sql)) {
300+
return;
301+
}
302+
303+
// Reverse the binds so that duplicate named binds
304+
// will be processed prior to the original binds.
305+
$binds = array_reverse($binds);
306+
307+
$this->finalQueryString = $this->matchNamedBinds($sql, $binds);
308+
}
307309
}
308310

309311
/**

0 commit comments

Comments
 (0)