无为清净楼资源网 Design By www.qnjia.com
本文实例讲述了ThinkPHP框架基于PDO方式连接数据库操作。分享给大家供大家参考,具体如下:
一 代码
1、修改config.php文件
<"htmlcode"><"Content-Type:text/html; charset=utf-8"); //设置页面编码格式 class IndexAction extends Action{ public function index(){ $db = M('User'); // 实例化模型类,参数数据表名称,不包含前缀 $select = $db->select(); // 查询数据 $this->assign('select',$select); // 模板变量赋值 $this->display(); // 指定模板页 } public function type(){ $dba = M('Type'); // 实例化模型类,参数数据表名称,不包含前缀 $select = $dba->select(); // 查询数据 $this->assign('select',$select); // 模板变量赋值 $this->display('type'); // 指定模板页 } } "htmlcode"><"/ThinkPHP.php"); //加载框架入口文件 App::run(); //实例化一个网站应用实例 "htmlcode"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>用户信息输出</title> <link href="__ROOT__/Public/Css/style.css" rel="external nofollow" rel="external nofollow" rel="stylesheet" type="text/css" /> </head> <body> <table width="405" border="1" cellpadding="1" cellspacing="1" bgcolor="#99CC33" bordercolor="#FFFFFF"> <tr> <td colspan="3" bgcolor="#FFFFFF" class="title" align="center">用户信息</td> </tr> <tr class="title"> <td bgcolor="#FFFFFF" width="44">ID</td> <td bgcolor="#FFFFFF" width="120">名称</td> <td bgcolor="#FFFFFF" width="223">地址</td> </tr> <volist name='select' id='user' > <tr class="content"> <td bgcolor="#FFFFFF"> {$user.id}</td> <td bgcolor="#FFFFFF"> {$user.user}</td> <td bgcolor="#FFFFFF"> {$user.address}</td> </tr> </volist> </table> </body> </html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>类别输出</title> <link href="__ROOT__/Public/Css/style.css" rel="external nofollow" rel="external nofollow" rel="stylesheet" type="text/css" /> </head> <body> <table width="405" border="1" cellpadding="1" cellspacing="1" bgcolor="#99CC33" bordercolor="#FFFFFF"> <tr> <td colspan="3" bgcolor="#FFFFFF" class="title" align="center">类别输出</td> </tr> <tr class="title"> <td bgcolor="#FFFFFF" width="44">ID</td> <td bgcolor="#FFFFFF" width="120">类别名称</td> <td bgcolor="#FFFFFF" width="223">添加时间</td> </tr> <volist name='select' id='type' > <tr class="content"> <td bgcolor="#FFFFFF"> {$type.id}</td> <td bgcolor="#FFFFFF"> {$type.typename}</td> <td bgcolor="#FFFFFF"> {$type.dates}</td> </tr> </volist> </table> </body> </html>二 运行结果
更多关于thinkPHP相关内容感兴趣的读者可查看本站专题:《ThinkPHP入门教程》、《thinkPHP模板操作技巧总结》、《ThinkPHP常用方法总结》、《codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《Zend FrameWork框架入门教程》及《PHP模板技术总结》。
希望本文所述对大家基于ThinkPHP框架的PHP程序设计有所帮助。
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年09月25日
2024年09月25日
- 纯音入心系列纯音乐《天籁古筝》1CD[MP3][331MB]
- 男女对唱典藏天碟《发烧对唱·那个季节里的歌DSD》10CD[WAV]
- 群星2010-歌林精选辑[歌林][WAV+CUE]
- TrioZimbalist-PianoTriosofWeinberg,Auerbach,Dvorak(2024)[24-44,1]wav
- 群星.1992-滚石第一流台湾歌·12王牌大车拼【滚石】【WAV+CUE】
- 林子祥.1984-创作歌集【华纳】【WAV+CUE】
- 周汤豪.2010-周汤豪【华纳】【FLAC分轨】
- Mozart-TheStringQuintets-AmadeusQuartet,CecilAronowitz(2017)[24-44,1][WAV+CUE]
- JamesWilliamsDennisIrwin-Focus(2024,Red)[24-48]FLAC
- 藤泽麻衣《空みあげて》[WAV]
- 纯音入心系列纯音乐《中国古筝经典名曲》1CD[MP3][1.3GB]
- 纯音入心系列纯音乐《古筝新奏:岁月静好与筝语,细水流年与筝同》1CD[MP3][846.9MB]
- 670《脆弱敏感小女生》[320K/MP3][27.53MB]
- 曾琳.2011-好好爱我【南方】【WAV+CUE】
- 范晓萱.1995-RAIN【福茂】【WAV+CUE】