Think\Model:relation方法不存在!

浏览:861 发布日期:2015/12/28 分类:求助交流
这是model<?php
    namespace Home\Model;
    use Think\Model;
    use Think\Model\RelationModel;
    class CollectionModel extends RelationModel{
        protected $_link = array(
            'Melody'=>array(
                'mapping_type' => self::MANY_TO_MANY,
                'class_name'  =>'Melody',
                //'mapping_name' =>'melody',
                'foreign_key' =>'collection_id',
                'relation_foreign_key' =>'melody_id',
                'relation_table' => '__COLLECTION_MELODY__'
            )
        )
    }
这是控制器<?php
namespace Home\Controller;
use Think\Controller;
class PublicActionController extends Controller {
    //推荐合辑
    public function recommend_collection(){
        $Col = D('Collection');
        $col=$Col->relation(true)->select();
        $this->assign('collectionList',$col);
                $this->display();
    }
}
然后它就relation不存在了
最佳答案
评论() 相关
后面还有条评论,点击查看>>