Home >php教程 >php手册 >ThinkPHP中的关联模型注意点

ThinkPHP中的关联模型注意点

WBOY
WBOYOriginal
2016-06-06 20:21:351221browse

这篇文章主要介绍了初学ThinkPHP中的关联模型注意点,需要的朋友可以参考下

初学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