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

ThinkPHP中的关联模型注意点

WBOY
Release: 2016-06-06 20:21:35
Original
1226 people have browsed it

这篇文章主要介绍了初学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',
),
);
}

Related labels:
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template