Array (& #39; mapping_type & #39; & gt; MANY_TO_MANY, & #39; foreign_key & #39; & gt; & #39; user_id & #39 ;, primary table external connection & #39; relation_key & #39; & gt; & #39; role_id & #39;, secondary table external connection & #39; relation_table & #39; & gt; & #39; tp_role_user & #39; intermediate table ));}? & Gt; & lt ;? PhpnamespaceAdminC php
Namespace Admin \ Model;
Use Think \ Model \ RelationModel;
Class UserModel extends RelationModel {
Protected $ tableName = 'user '; // define the name of the master table // define the association relationship Protected $ _ link = array ('role' => array ('ing ing _ type' => many_to_type, 'foreign _ key' => 'User _ id', // Main table output' relation _ key' => 'role _ id ', // associate table external 'Relation _ table' => 'TP _ role_user '// intermediate table ));
}
?>
Namespace Admin \ Controller;
Use Think \ Controller;
Use Home \ Model \ UserModel;
Use Think \ Model \ RelationModel;
Class RbacController extends CommonController {
Public function index (){
$ Result = D ('user')-> relation (true)-> select ();
Var_dump ($ result );
Die ();
$ This-> display ();
}