php - TP5 many-to-many association query reports an error. Can you help me find out where the problem is?
PHP中文网
PHP中文网 2017-07-05 10:46:01
0
1
928

1. I have just come into contact with TP5, and I am confused about the correlation model in the manual. I am here to ask for help~~ I hope you can get some answers. First post the error screenshot

#2. The model code is as follows

namespace app\index\model; use think\Model; class User extends Model{ public function group(){ //用户表 belongsToMany 用户组表(关联模型,中间表,关联id1,关联id2) return $this->belongsToMany('Group','auth_group_access','uid','group_id'); } }

3. The controller code is as follows

namespace app\index\controller; use think\Controller; use think\Db; use think\Request; use app\index\model\User as Usermodel; class User extends Controller{ //用户列表 public function index(){ $user = new Usermodel(); $data = $user->group; p($data);die; $this->assign('v',$data); return $this -> fetch(); } }
PHP中文网
PHP中文网

认证0级讲师

reply all (1)
Ty80

The id attribute does not exist. See how $notFound is obtained. Is there any missing parameters?

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!