PHP
·
发表于 5年以前
·
阅读量:8294
±¾ÎÄʵÀý½²ÊoÁËCI¿o¼ÜÊý¾Ý¿a²eѯ»º´aeÓÅ»¯µÄ½¨¡£*ÖÏi¸ø´o¼Ò¹(C)´o¼Ò²Î¿¼£¬¾ßÌaÈçÏ£º
CI¿o¼ÜÖÐÓиo±È½ÏºÃµÄ²eѯÓÅ»¯£¬¾ÍÊÇÊý¾Ý¿a»º´aeÓÅ»¯
1.¿ªÆo»º´ae
//ÔÚapplication/config.phpÖпªÆo
$db['default']['cache_on'] = TRUE;
//ÔÚapplication/config.phpÖпªÆo
$db['default']['cachedir'] = './cache';
//²¢ÔÚ¶ÔÓ¦µÄĿ¼ÖмÓÒ»¸o¿Éд»º´aeĿ¼cache
2. ÔÚ¶ÔÓ¦µÄ²eѯÖпªÆo»º´aeÓi¾a
// ´o¿ª»º´ae¿ª¹Ø
$this->db->cache_on();
$query = $this->db->query("SELECT * FROM mytable");
// ʹÏÂÃaeÕaÌo²eѯ²»±»»º´ae
$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");
3. Ìi¼ÓÏaÓ¦µÄ Ça¿Õ»º´ae
//»º´ae²»»a×Ô¶¯É¾³ý Ö»ÄÜÊÖ¶¯É¾³ý
//ÕaÑu Äa¿ÉÒÔÔÚ¶ÔÓ¦µÄ Ôo¸Äɾ Ói¾aÖÐÇa³ý»º´ae ¾ÍokÁË
//Ça¿ÕËuÓлº´ae
$this->db->cache_delete_all()
/*
Ça¿Õµ¥¸o»º´ae
example.com/index.php/blog/commentsµÄÒ³Ãae, »º´aeϵͳ»a°ÑËuÓÐÉu³ÉµÄ»º´aeÎļþ*Žø
Ò»¸oÒÔ blog+comments×oΪÃu³ÆµÄÎļþ¼ÐÀi. Èç¹uÄuҪɾ³ý¹ØÓÚ¸Õ²ÅÌaµ½µÄÕa¸oÀý×ÓÓe
Ö®¶ÔÓ¦µÄ»º´aeÎļþ ÐeÒªÖ´ÐÐÒÔÏ´uÂe:
*/
$this->db->cache_delete('/blog', 'comments');
¸u¶a¹ØÓÚCodeIgniterÏa¹ØÄÚÈݸÐÐËȤµÄ¶ÁÕ߿ɲe¿´±¾Õ¾×¨Ìa£º¡¶codeigniterÈeÃŽ̡̳¡¢¡¶CI(CodeIgniter)¿o¼Ü½ø½×½Ì³Ì¡¡¢¡¶phpÓÅÐa¿ª*¢¿o¼Ü×ܽa¡¡¢¡¶ThinkPHPÈeÃŽ̡̳¡¢¡¶ThinkPHP³£Óý¨×ܽa¡¡¢¡¶Zend FrameWork¿o¼ÜÈeÃŽ̡̳¡¢¡¶phpÃaeÏo¶ÔÏo³ÌÐoÉe¼ÆÈeÃŽ̡̳¡¢¡¶php+mysqlÊý¾Ý¿a²Ù×÷ÈeÃŽ̡̳¼°¡¶php³£¼uÊý¾Ý¿a²Ù×÷¼¼ÇÉ»a×Ü¡*
Ï£Íu±¾ÎÄËuÊo¶Ô´o¼Ò»uÓÚCodeIgniter¿o¼ÜµÄPHP³ÌÐoÉe¼ÆÓÐËu°iÖu¡£