模型关联保存获取主键ID

浏览:865 发布日期:2018/06/23 分类:ThinkPHP5专区 关键字: 模型关联 关联保存 自增ID
如何在一对多关联保存的时候,拿到关联模型的自增 ID ?    public function honestComment()
    {
        return $this->hasMany('HonestComment');
    }
            $honest = $this->find($handel);
            $honest->honestComment()->save([
                'create_by' => $data['create_by'],
                'content' => $data['content']
            ]);
我要拿到 honest_comment 表的新增 ID
最佳答案
评论( 相关
后面还有条评论,点击查看>>