美文网首页
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表关联

    // +-----------------------------------------------------...

  • 模型hasOne、hasMany、belongsTo详解

    ThinkPHP5有关联模型的操作,但有部分初学者对数据表中常见的几种表与表的关系还存在着问题,所以使用不好关联查...

  • mysql关联更新update

    mysql关联更新update,mysql关联修改 关联修改a表,将b表数据赋值给b表

  • flink维表关联系列之维表服务与Flink异步IO

    维表关联系列目录:一、维表服务与Flink异步IO二、Mysql维表关联:全量加载三、Hbase维表关联:LRU策...

  • Django关联,auth模块

    1.一对多关联 1.表内自关联是指表内数据相关联的对象和表是相同字段,这样我们就直接用表内关联将外键关联设置成自身...

  • thinkPHP5 "A non well forme

    MYSQL数据表中有个时间戳类型的字段,默认值为CURRENT_TIMESTAMP。 thinkPHP5查询该表的...

  • 关联关系查询(第一讲)

    关联查询 当查询内容涉及到具有关联关系的多个表时,就需要使用关联查询。根据表与表之间的关联关系的不同,关联查询分为...

  • 拆表、关联表

    拆表 将第一张表和竖着的第二张的关联 作业:第一张表的与第三张表的拆分及关联

  • mysql实现多表关联

    mysql实现多表关联 mysql关联单张表

  • MapReduce实现‘多表关联’

    多表关联和单表关联相似,都类似于数据库中的自然连接。相比单表关联,多表关联的左右表和连接列更加清楚。所以可以采用和...

网友评论

      本文标题:thinkphp5表关联

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