关于smarty缓存问题

tangzhoou90 2012-07-15 12:30:15
include("main.inc.php");
$smarty->caching=true;
$smarty->cache_lifetime="60*60*123";
$id=$_GET['id'];
$mysqli=new mysqli("localhost","root","123456","test");
$query="select * from user where id=$id";
if(!$smarty->is_cached("demo2.tpl",$id))
{
echo "sfd";
$result=$mysqli->query($query);
$arr=$result->fetch_assoc();
$smarty->assign("arr",$arr);
}

//如果不设置display的第二个参数,显然每次只会只读取缓存你文件,这不是我们想要看的结果
//$smarty->display("demo2.tpl");
//启用多页面的缓存
$smarty->display("demo2.tpl",$id);
?>
为什么会报错,,

Fatal error: Uncaught exception 'SmartyException' with message 'Call of unknown method 'is_cached'.' in D:\server\Apache2.2\htdocs\sutra\Smarty\sysplugins\smarty_internal_templatebase.php:755 Stack trace: #0 [internal function]: Smarty_Internal_TemplateBase->__call('is_cached', Array) #1 D:\server\Apache2.2\htdocs\sutra\smart\demo2.php(8): Smarty->is_cached('demo2.tpl', '19') #2 {main} thrown in D:\server\Apache2.2\htdocs\sutra\Smarty\sysplugins\smarty_internal_templatebase.php on line 755
...全文
235 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
赤道无风带 2013-07-24
  • 打赏
  • 举报
回复
好吧 情况是这么个情况 smarty3.x这个版本已经和smarty2.x有所区别了 smarty3.x自定义函数要用$smarty->registerPlugin(“function”,“tpl模板标签”,“你的自定义函数”)
okay456okay 2012-09-12
  • 打赏
  • 举报
回复
我的smarty 3, 下载的包是Smarty-3.1.11.tar.gz,使用 is_cached 提示:Fatal error: Uncaught exception 'SmartyException' with message 'Call of unknown method 'is_cached'.' ,但使用 isCached 能正常工作。
tangzhoou90 2012-07-16
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]

请检查你的 smarty 的版本号
is_cached 方法只适用于 smarty 3
对于 smarty 2 是 isCached
[/Quote]

还是唠叨哥牛逼!!!解决了呵呵,,牛叉啊
xuzuning 2012-07-16
  • 打赏
  • 举报
回复
请检查你的 smarty 的版本号
is_cached 方法只适用于 smarty 3
对于 smarty 2 是 isCached
tangzhoou90 2012-07-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

你在这开启缓存,浏览一次还会重新生成一次,你分配变了,缓存也跟着变。你自己定义个时间看看。
[/Quote]
怎么定义啊,我就是那判断错了,,那方法应该是这样的吧
zecool20 2012-07-15
  • 打赏
  • 举报
回复
你在这开启缓存,浏览一次还会重新生成一次,你分配变了,缓存也跟着变。你自己定义个时间看看。

4,250

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧