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

WBOY
Release: 2016-06-07 17:18:57
Original
795 people have browsed it

初学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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!