MANY_TO_MANY php多对多表的链接 返回的数组role=null为什么

WBOY
Release: 2016-06-02 11:27:54
Original
1012 people have browsed it

php

namespace Admin\Model;
use Think\Model\RelationModel;

class UserModel extends RelationModel {

<code> Protected $tableName = 'user';//定义主表名称 //定义关联关系 Protected $_link=array(    'role' =>array(        'mapping_type' =>MANY_TO_MANY,        'foreign_key' =>'user_id',//主表外联        'relation_key' =>'role_id',//副表外联        'relation_table' =>'tp_role_user'//中间表        )    );</code>
Copy after login

}
?>

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();
}

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
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!