Welcome Guest, Not a member yet? Register   Sign In
Database "data_cache" Not Updating
#1

(This post was last modified: 06-07-2016, 11:26 PM by JayAdra.)

So I am setting up a DB backup utility and came across this weird issue.

The data_cache in the "db" object stores the table names of the current database, which is fine, but it doesn't get updated when you switch databases.

I select one database (db1) and run the backup and it works fine. I select the second database (db2), but the table names don't get updated, so when backing up, it tries to run queries on tables which might not (and don't) exist in db2.

I've simplified my code to show the issue:

PHP Code:
$this->db->db_select('db1');
$a $this->db->list_tables();
$this->db->db_select('db2');
$b $this->db->list_tables();
print_r($a);
echo 
"--------------------";
print_r($b);
die; 

The result is the same list of tables from db1 being printed twice.

My question is, is there a way to rebuild/reset this cache easily? I figure I could just manually reset it using unset($this->db->data_cache['table_names']) but that doesn't seem ideal and may cause issues elsewhere?

Any advice is appreciated. Thanks!
Reply
Reply
#3

Legend.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB