表结构 现在有客户表.订单表.图书表.作者表, 客户表Customer (id customer_name) 订单表Order (id order_name customer_id book_id) 图书表Book (id book_name author_id) 作者表Author (id author_name) 模型定义 下面是这4个个模型的定义,只写出其中的关联 Customer class Customer ex
public function getMember1(){ return $this->hasOne(Member::className(), ['wechat_id' =>'toid']); } public function getMember2(){ return $this->hasOne(Member::className(), ['wechat_id' =>'fromid']); } [ 'label' =&
上一篇文章介绍了基于Mybatis对数据库的增.删.改.查.这一篇介绍下关联查询(join query). 三张表:user article blog 表的存储sql文件: /* Navicat MySQL Data Transfer Source Server : localhost Source Server Version : 50620 Source Host : localhost:3306 Source Database : mybatis Target Server Type :