Welcome Guest, Not a member yet? Register   Sign In
Running a same query multiple times?
#3

If it's exact same query, you probably ought to try and reuse values. Dependency injection would work quite well for this, or you could implement internal caching just for that model method:

PHP Code:
private $_get_content_cache null;

public function 
get_content()
{
    if (
is_null($this->_get_content_cache)) {
        
$q $this->db->get(...);
        
$this->_get_content_cache $q->result();
    }
    return 
$this->_get_content_cache;

Reply


Messages In This Thread
Running a same query multiple times? - by kaitenz - 09-10-2018, 10:47 PM
RE: Running a same query multiple times? - by Pertti - 09-11-2018, 12:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB