Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14115

how do I cache multiple databases (dynamic query)

$
0
0
Hi, 

I have 4 databases in the config. 

my model is something like: 


PHP Code:
function get_total($dbkey){
// this $dbkey is the additioanl databases specified in the config 

$thisdb $this->load->database($dbkeyTRUE);
$thisdb->cache_on();
$query $thisdb->query("select count(*) as total from dbname.tablename"); 
$row 
$query->row();
return 
$row; 
}  


and from the controller, I do something like 



PHP Code:
$this->load->model('mydb') 

$db2total_users 
$this->mydb->get_total("db2"):
$db3total_users $this->mydb->get_total("db3"):
$db4total_users $this->mydb->get_total("db4"):
$db5total_users $this->mydb->get_total("db5"): 


This works fine . with this I am able to connect to 4 additional database and pull all info @ once. 


The issue here is that the $thisdb->cache_on();  on the model is not working. The connection takes the same amount of time even if that line was not there.. and then, I do not see any pages being created on application/cache 

another thing to note, the profiler only shows the main $db query .. for the additional ones, it does not.

so how would I do db query cache here ? 


Thanks

Viewing all articles
Browse latest Browse all 14115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>