Hi I need to cache only one query in my CI app. I dont understand what to do now. For example I have this in my config/database.php
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = APPPATH . 'cache';
And this is my model:
public function get_languages() {
$this->db->cache_on();
$this->db->save_queries = TRUE;
log_message("error", "getLanguages!!!!!!!!!!!!!");
$this->db->from('tbl_language');
$result = $this->db->get();
$results = $result->result_array();
log_message("error", $this->db->last_query());
return $results;
}
I always see the query is executed in DB. Some help please! What is wrong?
below code worked me!
public function get_languages() {
$this->db->cache_on();
$this->db->save_queries = TRUE;
log_message("error", "getLanguages!!!!!!!!!!!!!");
$this->db->from('tbl_language');
$result = $this->db->get();
$results = $result->result_array();
var_dump($results);//print for checking
$count = $result->num_rows();
log_message("error", $this->db->last_query());
if($count>0)
{
foreach($results as $list)
{
echo $list['id'];
}
}
}