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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver CS6
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version
Useful JavaScript development tools
