thinkphp5表关联

// +----------------------------------------------------------------------

// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]

// +----------------------------------------------------------------------

// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.

// +----------------------------------------------------------------------

// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )

// +----------------------------------------------------------------------

// | Author:kane < [email protected]>

// +----------------------------------------------------------------------

namespace app\opera\model;

use think\Model;

class OperaPersonPostModel extends Model

{

    public function operaPosts()

{

        return $this->hasMany('app\opera\model\OperaPostModel', 'id', 'post_id');//post_id在本表

}

    public function operaPersons(){

        return $this->belongsTo('app\opera\model\OperaPersonModel','person_id','id');//person_id在本表

}

}

你可能感兴趣的:(thinkphp5表关联)