Skip to content

Instantly share code, notes, and snippets.

@narfbg
Created October 28, 2013 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save narfbg/7195165 to your computer and use it in GitHub Desktop.
Save narfbg/7195165 to your computer and use it in GitHub Desktop.
A simpler alternative to CodeIgniter#2698
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index a36501e..95c3af3 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -2551,11 +2551,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$qb_variable = 'qb_'.$val;
$qb_cache_var = 'qb_cache_'.$val;
- if (count($this->$qb_cache_var) === 0)
+ if (count($this->$qb_cache_var) > 0)
{
- continue;
+ foreach ($this->$qb_cache_var as &$cache_var)
+ {
+ in_array($cache_var, $this->$qb_variable, TRUE) OR $this->$qb_variable[] = $cache_var;
+ }
}
- $this->$qb_variable = array_merge($this->$qb_variable, array_diff($this->$qb_cache_var, $this->$qb_variable));
}
// If we are "protecting identifiers" we need to examine the "from"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment