The example in this article describes the method of Yii opening fragment caching. Share to everyone for your reference, specific as follows:
1, in the main.php file in the components add:
Cache ' =>array (
' class ' => ' System.caching.CFileCache ',
),
2, in view where the need to cache to add this sentence
<?php if ($this->begincache (' aaa ',
Array (
' duration ' =>3360,
' VaryByParam ' =>array (' page ') ,
' Dependecy ' =>array (
' class ' => ' system.caching.CDbCacheDependency ',
' SQLL ' => ' select count (server) from {{Game_serve}} ',
/Set dependent cache, if this statement is changed, cached and new
,))
{//
here is no caching left, The above set cache time, and set the change cache, if there is no paging does not need the last parameter
}
?>
//End caching here, when there is no cache to go below this if end will also cache the information, currently cached in the runtime folder
More about Yii related content readers can view the site topics: "Yii framework Introduction and common skills Summary", "PHP Excellent Development Framework Summary", "Smarty Template Primer Tutorial", "PHP date and Time usage summary", "PHP object-oriented Programming Program", " Summary of PHP string usage, Introduction to PHP+MYSQL database operations, and a summary of PHP common database operations Tips
I hope this article will help you with the PHP program design based on the YII framework.