Relevance model considerations in ThinkPHP

  • 2021-06-29 10:38:18
  • OfStack

When first learning ThinkPHP, there is one error-prone point in the association model in ThinkPHP. Here is an example:
Tables to be used: id_elite_major and id_elite_student
Examples of code are as follows:

class EliteMajorModel extends RelationModel{
protected $_link=array(
'EliteStudent'=>array(
'mapping_type'=>HAS_MANY,  // Error prone point :  Here at  HAS_MANY  Add often  ''  Easy to write  'HAS_MANY' Leading to errors 
'class_name'=>'EliteStudent',
'foreign_key'=>'mid',
'mapping_name'=>'studentslist',
),
);
}


Related articles: