关于一个model中有多个关系模型,应该怎么使用??

浏览:484 发布日期:2018/04/26 分类:求助交流 关键字: relation 关联模型
RT,我这里面有两个关系模型,但是controller中应该怎么分别调用这两个关系呢??protected $_link = array(
     /*
     *关联模型'carmodel' 从属于'car' 表
     */
        'car' => array(
            'mapping_type'  => self::BELONGS_TO,
            'foreign_key'   => 'car_name_id',//外键
            'mapping_fields'=> 'carname',//需要显示的关联表的字段
            'as_fields'     => 'carname',//同级显示字段的名称
        ),
     /*
     *关联模型'carmodel' 一对多 'sellgoods' 表
     */
        'sellgoods' => array(
            'mapping_type'  => self::HAS_MANY,
            'mapping_name'  => 'sellname',
            'foreign_key'   => 'sell_goods_id',
            'relation_deep' => 'true'
        )
    );
 $ee = D('carmodel');
        $eee = $ee->Relation('true')->select();
        var_dump($eee);
controller中的代码
最佳答案
评论( 相关
后面还有条评论,点击查看>>