<?php class ExpertiseModel extends RelationModel { protected $_link=array( 'Role'=> array( 'mapping_type'=>BELONGS_TO, 'foreign_key'=>'rid', //主表在中间表中的关联字段名称 就是Expertise表的外键 'relation_key'=>'id', //副表在中间表中的关联字段名称 就是Role表的主键 'mapping_name'=>'user_maping', 'mapping_fields'=>'name', 'as_fields'=>'name', ), ); }