• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.