<?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不存在了 最佳答案