Home  >  Article  >  Backend Development  >  ThinkPHP中的关联模型注意点_php实例

ThinkPHP中的关联模型注意点_php实例

WBOY
WBOYOriginal
2016-06-07 17:18:57780browse

初学ThinkPHP时,ThinkPHP中的关联模型有一处易错点,现举例如下:
需用到的表:id_elite_major和id_elite_student
代码举例如下:

复制代码 代码如下:
class EliteMajorModel extends RelationModel{
protected $_link=array(
'EliteStudent'=>array(
'mapping_type'=>HAS_MANY,  //易错点: 此处在 HAS_MANY 时常会加上 '' 容易写成 'HAS_MANY',导致出错
'class_name'=>'EliteStudent',
'foreign_key'=>'mid',
'mapping_name'=>'studentslist',
),
);
}
Statement:
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