class GoodsModel extends BaseModel{var $table = ‘goods’;var $prikey = ‘goods_id’;var $alias = ‘g’;//缩写var $_name = ‘goods’;var $temp; // 临时变量var $_relation = array(// 一个商品对应一条商品统计记录‘has_goodsstatistics’ => array(‘model’ => ‘goodsstatistics’,‘type’ => HAS_ONE,‘foreign_key’ => ‘goods_id’,‘dependent’ => true),// 一个商品对应多个规格‘has_goodsspec’ => array(‘model’ => ‘goodsspec’,‘type’ => HAS_MANY,‘foreign_key’ => ‘goods_id’,‘dependent’ => true),// 一个商品对应一个默认规格‘has_default_spec’ => array(‘model’ => ‘goodsspec’,‘type’ => HAS_ONE,‘refer_key’ => ‘default_spec’,‘foreign_key’ => ‘spec_id’,),// 一个商品对应多个属性‘has_goodsattr’ => array(‘model’ => ‘goodsattr’,‘type’ => HAS_MANY,‘foreign_key’ => ‘goods_id’,‘dependent’ => true),// 一个商品对应多个图片‘has_goodsimage’ => array(‘model’ => ‘goodsimage’,‘type’ => HAS_MANY,‘foreign_key’ => ‘goods_id’,‘dependent’ => true),// 一个商品只能属于一个店铺‘belongs_to_store’ => array(‘model’ => ‘store’,‘type’ => BELONGS_TO,‘foreign_key’ => ‘store_id’,‘reverse’ => ‘has_goods’,),// 商品和分类是多对多的关系‘belongs_to_gcategory’ => array(‘model’ => ‘gcategory’,‘type’ => HAS_AND_BELONGS_TO_MANY,‘middle_table’ => ‘category_goods’,‘foreign_key’ => ‘goods_id’,‘reverse’ => ‘has_goods’,),// 商品和会员是多对多的关系(会员收藏商品)‘be_collect’ => array(‘model’ => ‘member’,‘type’ => HAS_AND_BELONGS_TO_MANY,‘middle_table’ => ‘collect’,‘foreign_key’ => ‘item_id’,‘ext_limit’ => array(‘type’ => ‘goods’),‘reverse’ => ‘collect_goods’,),// 商品和推荐类型是多对多的关系 todo‘be_recommend’ => array(‘model’ => ‘recommend’,‘type’ => HAS_AND_BELONGS_TO_MANY,‘middle_table’ => ‘recommended_goods’,‘foreign_key’ => ‘goods_id’,‘reverse’ => ‘recommend_goods’,),);var $_autov = array(‘goods_name’ => array(‘required’ => true,‘filter’ => ‘trim’,),);} |