兹有用户表user和评论表comment

public function returnmany() { return $this->hasOne(‘commnet‘,‘uid‘,‘user_id‘); } #uid 是comment表里的内容;user_id是user表里的内容
public function comm() { return $this->hasMany(‘commnet‘,‘uid‘,‘user_id‘); } #uid 是comment表里的内容;user_id是user表里的内容
可以通过访问属性的方法获取comm的返回值


一对多之新增

一对多批量新增

关系模型


关联过滤查询

根据字段查找

把查询语句作为对象操作的方法





原文:https://www.cnblogs.com/saintdingspage/p/10162075.html