开发者社区> 问答> 正文

thinkphp5引入db问题?报错


<?php
namespace app\index\controller;
use think\Db;
class Index
{
    public function index()
    {
	Db::table('users')->where('id',1)->find();
        
    }
}



请问怎么引入Db,这样报错


[2] ErrorException in Db.php line 114


call_user_func_array() expects parameter 1 to be a valid callback, class 'think\db\driver\Mysql' does not have a method 'table'

展开
收起
爱吃鱼的程序员 2020-06-09 15:39:34 637 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    太简单了吗,没人回

    自己写类不是要继承Controller类么?是不是这里的问题。

    2020-06-09 15:39:50
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
32 Tips to Boost MongoDB Perfo 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载