豢谜练登识病按眯插新卑峭妈
Db类:D:\phpStudy\PHPTutorial\WWW\tp5\thinkphp\library\think\Db.php
生成器:D:\phpStudy\PHPTutorial\WWW\tp5\thinkphp\library\think\db\Builder.php
连接器:D:\phpStudy\PHPTutorial\WWW\tp5\thinkphp\library\think\db\Connection.php
查询器:D:\phpStudy\PHPTutorial\WWW\tp5\thinkphp\library\think\db\Query.php
连接器目录:D:\phpStudy\PHPTutorial\WWW\tp5\thinkphp\library\think\db\connector
支持多种数据库
如需要使用其他数据库,将文件放入连接器目录,命名空间需要为下图所示:
查询id=6的小龙女的信息
D:\phpStudy\PHPTutorial\WWW\tp5\application\index\controller\Index.php:
<?php namespace app\index\controller; use think\Db; class Index { public function index() { dump( Db::table('staff') ->where('id',6) ->find() ); } }
执行:
结果集只需要name,salary字段
D:\phpStudy\PHPTutorial\WWW\tp5\application\index\controller\Index.php:
<?php namespace app\index\controller; use think\Db; class Index { public function index() { dump( Db::table('staff') ->field(['name','salary']) ->where('id',6) ->find() ); } }
执行:
酸保咎埠棘衅夹烤粉咳峡炊皖