summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2017-01-17 11:44:19 +0100
committerAndrey Andreev <narf@devilix.net>2017-01-17 11:45:24 +0100
commit437ffe035f6715d97983908d6a761ae0a23767f1 (patch)
tree03f30e493fed73884c79e48e93dcb79e38e91f38
parent71d8f72ffc48a7f46747b3b6b1a554533cc1cbc5 (diff)
Merge pull request #4987 from tianhe1986/develop_qb_alias_table_cache
Add aliased tables cache in query_builder.
-rw-r--r--system/database/DB_query_builder.php24
1 files changed, 15 insertions, 9 deletions
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 6b0e03274..0abf2a260 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -215,6 +215,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
protected $qb_cache_join = array();
/**
+ * QB Cache aliased tables list
+ *
+ * @var array
+ */
+ protected $qb_cache_aliased_tables = array();
+
+ /**
* QB Cache WHERE data
*
* @var array
@@ -2281,9 +2288,14 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$table = trim(strrchr($table, ' '));
// Store the alias, if it doesn't already exist
- if ( ! in_array($table, $this->qb_aliased_tables))
+ if ( ! in_array($table, $this->qb_aliased_tables, TRUE))
{
$this->qb_aliased_tables[] = $table;
+ if ($this->qb_caching === TRUE && ! in_array($table, $this->qb_cache_aliased_tables, TRUE))
+ {
+ $this->qb_cache_aliased_tables[] = $table;
+ $this->qb_cache_exists[] = 'aliased_tables';
+ }
}
}
}
@@ -2626,7 +2638,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
'qb_cache_orderby' => array(),
'qb_cache_set' => array(),
'qb_cache_exists' => array(),
- 'qb_cache_no_escape' => array()
+ 'qb_cache_no_escape' => array(),
+ 'qb_cache_aliased_tables' => array()
));
return $this;
@@ -2677,13 +2690,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
$this->qb_no_escape = $qb_no_escape;
}
}
-
- // If we are "protecting identifiers" we need to examine the "from"
- // portion of the query to determine if there are any aliases
- if ($this->_protect_identifiers === TRUE && count($this->qb_cache_from) > 0)
- {
- $this->_track_aliases($this->qb_from);
- }
}
// --------------------------------------------------------------------