diff options
author | Andrey Andreev <narf@devilix.net> | 2017-01-17 11:44:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-17 11:44:19 +0100 |
commit | 44c7af639ac1726780b64fb5a6cb6fca2df8b651 (patch) | |
tree | 2640697d933af4b6dc41daef3e7eb79c271241ee /system/database/DB_query_builder.php | |
parent | 9e17059bf8d277058d1de23390e388b5fa0cc26a (diff) | |
parent | b044cc3aa55de4c54f6c28b0ad90f4a8534b5c72 (diff) |
Merge pull request #4987 from tianhe1986/develop_qb_alias_table_cache
Add aliased tables cache in query_builder.
Diffstat (limited to 'system/database/DB_query_builder.php')
-rw-r--r-- | system/database/DB_query_builder.php | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 74eb015e4..fe4cf6993 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'; + } } } } @@ -2625,7 +2637,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; @@ -2676,13 +2689,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); - } } // -------------------------------------------------------------------- |