Welcome Guest, Not a member yet? Register   Sign In
AR library : remove cache methods?
#1

[eluser]xwero[/eluser]
Lately i'm beginning to wonder if there is the real benefit when using the cache methods?

A lot of people use the cache methods when they have to get two different things from the same table like the number of rows and the rows themselves but most of the times the num_rows method is sufficient.

Instead of the cache methods i'm starting to use arrays and variables for not having to redefine the sql statement parts.
Code:
$this->db->start_cache();
$this->db->from('table');
$this->db->where(array('id'=>1,'time'=>'12:00:00'));
$this->db->stop_cache();

$this->db->select('number');
$query1 = $this->db->get();

$this->db->select('name');
$query2 = $this->db->get();
$this->db->flush_cache();
// VS
$table = 'table';
$where = array('id'=>1,'time'=>'12:00:00');  

$this->db->select('number');
$this->db->from($table);
$this->db->where($where);
$query1 = $this->db->get();

$this->db->select('name');
$this->db->from($table);
$this->db->where($where);
$query2 = $this->db->get();
Normally i'm not found on copying lines but once the queries are getting more complex i noticed the cache methods are more in the way than helping to reduce the code i have to write. Not adding the flush_cache method caused me a lot of time loss. When using variables and arrays you don't have to flush the DB object values.

What is your view on the cache methods?


Messages In This Thread
AR library : remove cache methods? - by El Forum - 09-29-2008, 03:45 AM
AR library : remove cache methods? - by El Forum - 09-29-2008, 04:50 AM
AR library : remove cache methods? - by El Forum - 09-29-2008, 05:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB