Last active
December 28, 2015 03:29
-
-
Save GDmac/7435165 to your computer and use it in GitHub Desktop.
CI merge cache, QB/AR no escape
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php | |
index f0fe96c35622a77066952d6a23fc526044590df7..d912540b5e2cd825b705088bee2497ba72fd04aa 100644 | |
--- a/system/database/DB_query_builder.php | |
+++ b/system/database/DB_query_builder.php | |
@@ -2561,14 +2561,30 @@ abstract class CI_DB_query_builder extends CI_DB_driver { | |
{ | |
$qb_variable = 'qb_'.$val; | |
$qb_cache_var = 'qb_cache_'.$val; | |
- $qb_new = $this->$qb_cache_var; | |
- | |
- foreach ($this->$qb_variable as &$qb_var) | |
+ | |
+ // prep arrays with cached values | |
+ $qb_new = $this->$qb_cache_var; | |
+ $qb_escape = $this->qb_cache_no_escape; | |
+ | |
+ foreach ($this->$qb_variable as $i => &$qb_var) | |
{ | |
- in_array($qb_var, $qb_new, TRUE) OR $qb_new[] = $qb_var; | |
+ if ( ! in_array($qb_var, $qb_new, TRUE)) | |
+ { | |
+ $qb_new[] = $qb_var; | |
+ if ($val == 'select') $qb_escape[] = $this->qb_no_escape[$i]; | |
+ } | |
+ else | |
+ { | |
+ // if ($val == 'select') | |
+ // { | |
+ // i don't feel like doing an expensive | |
+ // foreach lookup, just to override escape? | |
+ // } | |
+ } | |
} | |
$this->$qb_variable = $qb_new; | |
+ if ($val == 'select') $this->qb_no_escape = $qb_escape; | |
} | |
// If we are "protecting identifiers" we need to examine the "from" | |
@@ -2577,10 +2593,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { | |
{ | |
$this->_track_aliases($this->qb_from); | |
} | |
- | |
- $this->qb_no_escape = array_merge($this->qb_no_escape, array_diff($this->qb_cache_no_escape, $this->qb_no_escape)); | |
} | |
- | |
// -------------------------------------------------------------------- | |
/** |
nope, the else part "could" be used to loop thru previously stored select variables and change the escape setting.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is the else condition necessary?