prepare($row_fid);$stmt->execu">
时间:2021-07-01 10:21:17 帮助过:26人阅读
//所有版块@$row_fid = "SELECT * FROM `forum_forum` ORDER BY `displayorder` ASC";$stmt = $pdo->prepare($row_fid);$stmt->execute();$row_forum = $stmt->fetchAll(PDO::FETCH_ASSOC); //主题分类 foreach ($row_forum as $key => $value) { $fid = $value["fid"]; @$sql = "SELECT `typeid`,`name` FROM `forum_topic_type` WHERE `fid` = $fid"; $stmt = $pdo->prepare($sql); $stmt->execute(); $row_type = $stmt->fetchAll(PDO::FETCH_ASSOC); } print_r($row_type);$smarty -> assign("all_forum",$row_forum);
另外也补充问个问题
我用SMARTY自己做 modifier.xxx.php 这类插件时,平时是常想顺利的
但为什么一用到数据库就完全不行?
我是用PDO的
因为没把$pdo这类句柄传入? 但是这种插件是由 模板直接调用,我根本就不能加入$pdo
我也试过加插件的function 内引入数据库文件,但也是表示数据库操作有误
请问有什么解决方案吗? 还是插件这部分根本不能操作数据库???
哪一步没成功?$row_type没值吗?
1.通过模板处理:类表 关联 子类表 得出结果集,在进行smarty的assign,模板循环2次 。
2.通过程序查询结果集处理:返回结果集,在程序组装成为字符串,直接assign传到模板。
//所有版块@$row_fid = "SELECT * FROM `forum_forum` ORDER BY `displayorder` ASC";$stmt = $pdo->prepare($row_fid);$stmt->execute();$row_forum = $stmt->fetchAll(PDO::FETCH_ASSOC); //主题分类 foreach ($row_forum as $key => $value) { $fid = $value["fid"]; @$sql = "SELECT `typeid`,`name` FROM `forum_topic_type` WHERE `fid` = $fid"; $stmt = $pdo->prepare($sql); $stmt->execute(); $row_forum[$key]['list'] = $stmt->fetchAll(PDO::FETCH_ASSOC); } print_r($row_forum);$smarty -> assign("all_forum",$row_forum);