入口文件:

配置文件:

数据库配置:

当你在database.php配置好你的数据库信息后,就可以在/application/index/controller/index.php中进行数据库操作,参考下面的代码:
(被注释的代码,看不懂没有关系,我们下一篇博文继续学习~)
<?php/** * namespace 命名空间 */namespace app/index/controller;use think/Controller;use think/Db;class Index extends Controller{ public function index($name = 'iwanghang') { echo $name.'<br>'; PRint_r($this->request->param()); // http://localhost:8888/myPhpDemo/ThinkPhp5.0.5/ThinkPHP_full_v5.0.5/public/index/index/index/aa/11/bb/22/cc/33 // 上面的连接的打印结果:Array ( [aa] => 11 [bb] => 22 [cc] => 33 ) /** * 查询users表信息并打印 */ $data = Db::name('users')->find(); print_r($data);// $this->aasign('data',$data);// $this->aasign('name',name);// return $this->fetch(); return '<style type="text/CSS">*{ padding: 0; margin: 0; } .think_default_text{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span></p><span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="http://tajs.QQ.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/Javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_bd568ce7058a1091"></thinkad>'; }}转载请注明出处:http://blog.csdn.net/iwanghang/article/details/56844460欢迎移动开发爱好者交流沈阳或周边城市公司有意开发Android,请与我联系联系方式
微信:iwanghangQQ:413711276邮箱:iwanghang@qq.com觉得博文有用,请点赞,请评论,请关注,谢谢!~
新闻热点
疑难解答