代码改变世界

thinkphp5 操作数据库方法

2020-08-01 15:12  idea555  阅读(141)  评论(0)    收藏  举报

<?php
namespace app\index\controller;
use think\Db;
use think\Controller;
class Index extends Controller
{
public function index()
{
return '上课来';
//return $this -> fetch();
}

// 使用配置文件连接数据库
public function data()
{
// 实例化数据库系统类
$DB = NEW DB;
// 查询数据,表名为UU的所有数据
$DATA = $DB::TABLE("employ") -> SELECT();
// 使用SQL语句
$DATA = $DB::QUERY("SELECT * FROM employ");
DUMP($DATA);
//

}

public function data1()
{
$userInfo22 = db::table('employ')
->where(array('Id'=>2))->find();

dump($userInfo22);
}
}