![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
我的网页是这样设计的:
从MYSQL数据库读出数据,用SMARTY模板调出网页,缓存时间设3600秒.
在缓存的这段时间,网页是不会显示新的数据了,但是不知道还会调数据库吗?占用数据库资源吗?
因为程序是先读MYSQL,再读入SMARTYR的.
比如这样:
<?
include "config.php";
$text="";
$str="select name from tabal";
$res=mysql_db_query($data,$str);
for($i=0;$i<6;$i++)
{
$row=mysql_fetch_row($res);
$text[$i]=$row[name];
}
$inew="6";
//引用类文件
require 'smarty/libs/Smarty.class.php';
$smarty = new Smarty;
$smarty->template_dir = "smarty/templet";
$smarty->compile_dir = "smarty/templates/templates_c";
$smarty->config_dir = "smarty/templates/config";
$smarty->cache_dir = "smarty/templates/cache";
$smarty->caching=true;
$smarty->cache_lifetime =3600;
$smarty->assign('count', $inew);
$smarty->assign("LEINAME",$text);
$fileurl="index.html";
$smtpl="01";
$smarty->display($fileurl,$smtpl);
?>
[ 本帖最后由 网逍遥 于 2007-4-17 01:53 PM 编辑 ]

