当前位置:网站首页>TP6 的 each 遍历用法
TP6 的 each 遍历用法
2022-04-23 05:57:00 【自己收藏学习】
闭包,查出来的赋值给topic_num属性 $chapterObj = (new TopicChapter()) ->where('question_bank_id', '=', $questionBankId) ->where('is_deleted', '=', 0) ->where('chapter_type', '=', 1) ->order('sort ASC') ->field('id as chapter_id,chapter_name') ->select(); $chapterObj->each(function ($item) use ($questionBankId) { $item->topic_num = (new \app\common\model\v2\Topic())->where(['question_bank_id' => $questionBankId, 'topic_chapter_id' => $item->chapter_id, 'parent_id' => 0, 'is_deleted' => 0, 'organization_id' => 3])->count('id'); });
版权声明
本文为[自己收藏学习]所创,转载请带上原文链接,感谢
https://blog.csdn.net/pksport/article/details/123442678
边栏推荐
猜你喜欢
随机推荐
1-2 JSX语法规则
1-5 NodeJS CommonJs规范
.Net Core 下使用 Quartz —— 【7】作业和触发器之简单触发器
el-date-picker限制选择范围,从当前时间到两个月前
Method of MySQL password expiration
New formdata() when importing files
JS手写兼容性事件绑定
手动实现简单的Promise及其基础功能
Leak detection and filling (I)
自用学习笔记-connectingString配置
小米摄像头异常解决
ASP.NET CORE 依赖注入服务生命周期
Mailbox string judgment
如何使用input表单向服务发送(占用较小)图片文件(body传输)?涉及到FileReader内置对象
TypeScript(下)
window环境下使用小皮面板安装redis
.Net Core 下使用 Quartz —— 【1】快速开始
初步认识Promse
useCenterHook
WebSocket(基础)