Welcome Guest, Not a member yet? Register   Sign In
caching a single query of databse
#1

[eluser]dhananjay[/eluser]
i just want this query to be cached as i have read in codeigniter manual
$result = $this->db->get('schools');

the school table has large no. of rows and it make page slow whenever i call this

so i added these functions before this call in my file
like this
$this->db->start_cache();
$result = $this->db->get('schools');
$this->db->stop_cache();

and also i have set path of caching directory in config database.php
but i have not enabled caching in database.php
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = 'application/cache';

i have not enabled cache here because i guessed if i will enable here it will stsrt caching or all queries but i dont want it for all i just want it for

$result = $this->db->get('schools');

i have looked in cache directory and its not caching any thing

if anyone can help me with this i will be much obliged
#2

[eluser]Sagar Ratnaparkhi[/eluser]
Try This...
Code:
// Turn caching on
$this->db->cache_on();
$result = $this->db->get(‘schools’);
// Turn caching off for this one query
$this->db->cache_off();




Theme © iAndrew 2016 - Forum software by © MyBB