您的位置:首页 > 编程语言 > PHP开发

thinkphp 关联模型配置代码

2015-06-23 23:26 543 查看
原文:thinkphp 关联模型配置代码
<?php
/**
* 公司与部门关联模型
*/
class CompanyRelationModel extends RelationModel{

//主表名称
protected $tableName = 'company';

//定义关联关系
protected $_link = array(

//关联表名称
'department' => array(
'mapping_type'        =>     MANY_TO_MANY,                //多对多关系
'foreign_key'        =>    'company_id',                //主表外键
'relation_key'        =>    'department_id',            //关联表外键
'relation_table'    =>    'sys_company_department',    //中间表(员工对应角色表),
'mapping_fields'    =>     'id, name, pId'                //关联表显示字段
)
);

}
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: