美文网首页
thinkphp5表关联

thinkphp5表关联

作者: chaosii | 来源:发表于2017-12-31 17:50 被阅读0次

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

    // | 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 < chengjin005@163.com>

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

    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表关联

          本文链接:https://www.haomeiwen.com/subject/udsagxtx.html