开发者

Static variable mechanism in CodeIgniter

I want to display business count which added in my system to my home page, but开发者_开发技巧 I don't want to perform a select query every time.

It will happen only once to initialize that business count global variable when new business added admin will refresh that count.

Is there any provision to do this in CodeIgniter?


You could either write to a file or use Query caching

// Turn caching on
$this->db->cache_on();
$query = $this->db->query("SELECT * FROM mytable");

// Turn caching off for this one query
$this->db->cache_off();
$query = $this->db->query("SELECT * FROM members WHERE member_id = '$current_user'");

// Turn caching back on
$this->db->cache_on();
$query = $this->db->query("SELECT * FROM another_table"); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜