summaryrefslogtreecommitdiffstats
path: root/system/database/DB_forge.php
diff options
context:
space:
mode:
authorTimothy Warren <tim@timshomepage.net>2012-06-12 13:45:45 +0200
committerTimothy Warren <tim@timshomepage.net>2012-06-12 13:45:45 +0200
commitb30a7c0d53c5dae5dab2311f777d67f639a5cee4 (patch)
treed518bc938a5d8458a55277d9adaa7d8fdcc9f1d3 /system/database/DB_forge.php
parent3902e383b41c6c0ef77b65e95d451cb2ea3d85db (diff)
parent4e9538fe19b09c0dc588542cfb7f793348b83bf7 (diff)
Merge upstream
Diffstat (limited to 'system/database/DB_forge.php')
-rw-r--r--system/database/DB_forge.php54
1 files changed, 51 insertions, 3 deletions
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index ff5eb3fe6..9b7639289 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -72,6 +72,11 @@ abstract class CI_DB_forge {
return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
}
+ if ( ! empty($this->db->data_cache['db_names']))
+ {
+ $this->db->data_cache['db_names'][] = $db_name;
+ }
+
return TRUE;
}
@@ -99,6 +104,15 @@ abstract class CI_DB_forge {
return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
}
+ if ( ! empty($this->db->data_cache['db_names']))
+ {
+ $key = array_search(strtolower($db_name), array_map('strtolower', $this->db->data_cache['db_names']), TRUE);
+ if ($key !== FALSE)
+ {
+ unset($this->db->data_cache['db_names'][$key]);
+ }
+ }
+
return TRUE;
}
@@ -209,7 +223,18 @@ abstract class CI_DB_forge {
$sql = $this->_create_table($this->db->dbprefix.$table, $this->fields, $this->primary_keys, $this->keys, $if_not_exists);
$this->_reset();
- return is_bool($sql) ? $sql : $this->db->query($sql);
+
+ if (is_bool($sql))
+ {
+ return $sql;
+ }
+
+ if (($result = $this->db->query($sql)) !== FALSE && ! empty($this->db->data_cache['table_names']))
+ {
+ $this->db->data_cache['table_names'][] = $$this->db->dbprefix.$table;
+ }
+
+ return $result;
}
// --------------------------------------------------------------------
@@ -231,7 +256,19 @@ abstract class CI_DB_forge {
return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
}
- return $this->db->query(sprintf($this->_drop_table, $this->db->escape_identifiers($this->db->dbprefix.$table_name)));
+ $result = $this->db->query(sprintf($this->_drop_table, $this->db->escape_identifiers($this->db->dbprefix.$table_name)));
+
+ // Update table list cache
+ if ($result && ! empty($this->db->data_cache['table_names']))
+ {
+ $key = array_search(strtolower($this->db->dbprefix.$table_name), array_map('strtolower', $this->db->data_cache['table_names']), TRUE);
+ if ($key !== FALSE)
+ {
+ unset($this->db->data_cache['table_names'][$key]);
+ }
+ }
+
+ return $result;
}
// --------------------------------------------------------------------
@@ -255,10 +292,21 @@ abstract class CI_DB_forge {
return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
}
- return $this->db->query(sprintf($this->_rename_table,
+ $result = $this->db->query(sprintf($this->_rename_table,
$this->db->escape_identifiers($this->db->dbprefix.$table_name),
$this->db->escape_identifiers($this->db->dbprefix.$new_table_name))
);
+
+ if ($result && ! empty($this->db->data_cache['table_names']))
+ {
+ $key = array_search(strtolower($this->db->dbprefix.$table_name), array_map('strtolower', $this->db->data_cache['table_names']), TRUE);
+ if ($key !== FALSE)
+ {
+ $this->db->data_cache['table_names'][$key] = $this->db->dbprefix.$new_table_name;
+ }
+ }
+
+ return $result;
}
// --------------------------------------------------------------------