1.剛接觸TP5,看了手冊裡的關聯模型也是雲裡霧裡,上來求助下~~還望解答。先貼上報錯截圖
#2.模型程式碼如下
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.控制器程式碼如下
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();
}
}