diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-06-12 20:48:13 +0200 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-06-12 20:48:13 +0200 |
commit | 29953ddc989e2ae26afedefd99e347f2d692d0ec (patch) | |
tree | 0d05d82cd37dbe9594997b6ce1e8942abe205540 /system/database | |
parent | 324dadd2296649803f762eaffac3521943305400 (diff) |
Additional improvements to compile_binds()
Diffstat (limited to 'system/database')
-rw-r--r-- | system/database/DB_driver.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 63d3372cf..e0266b2b6 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -596,7 +596,12 @@ abstract class CI_DB_driver { */ public function compile_binds($sql, $binds) { - if (preg_match_all('/(>|<|=|!|BETWEEN\s|AND\s)\s*('.preg_quote($this->bind_marker).')/i', $sql, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE) !== count($binds)) + if (empty($binds)) OR empty($this->bind_marker)) + { + return $sql; + } + elseif (preg_match_all('/(>|<|=|!|BETWEEN\s|AND\s)\s*('.preg_quote($this->bind_marker).')/i', + $sql, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE) !== count($binds)) { return $sql; } @@ -610,10 +615,9 @@ abstract class CI_DB_driver { $binds = array_values($binds); } - - for ($i = count($matches) - 1; $i >= 0; $i--) + for ($i = count($matches) - 1, $l = strlen($this->bind_marker); $i >= 0; $i--) { - $sql = substr_replace($sql, $this->escape($binds[$i]), $matches[$i][2][1], 1); + $sql = substr_replace($sql, $this->escape($binds[$i]), $matches[$i][2][1], $l); } return $sql; |