<?php
namespace Admin\Model;
use Think\Model;
use Think\Model\RelationModel;
class ArticleModel extends RelationModel{
protected $_link = array(
'categorytype' => array(
'mapping_type' =>self::BELONGS_TO,//是主表的父表关系
'class_name' => 'category',//关联表名称
'foreign_key' => 'categoryarticle',//主表的外键关联字段
//'relation_key' =>'sortnumber',
// 'parent_key' => 'categoryarticle',
// 'mapping_fields'=>'categorytype',
'as_fields' => 'categorytype',
),
);
/**
* 1,模型名称即数据表名称
* 2,模型文件名,模型类名称,首字母必须大写
* 3,关联模型 需引用RelationModel 并继承
* use Think\Model\RelationModel;
class ArticleModel extends RelationModel{protected $_link = array();}
4,数据库表字段名称必须小写字母
5,如果父表没有指定主键,默认以父表的id字段作为关联字段
*/
}
?>
联系客服