当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
Leak detection and vacancy filling (III)
查漏补缺(九)---程序篇
thinkphp5 ---- object(think\response\Json)转数组
Header内置对象
Database programming of node
浏览器中堆栈内存的底层处理
【关于数据库的简易认识】
excel里有文字的数字怎么从小到大排序,而不是首数字排序
JS实现网页轮播图
Unity3D对象池的理解与小例子
1-2 JSX语法规则
freeCodeCamp----shape_calculator练习
window环境下使用小皮面板安装redis
Your brain expands and shrinks over time — these charts show how
.Net Core 下使用 Quartz —— 【6】作业和触发器之触发器的日历
leetcode刷题之x的算术平方根
1-4 NodeJS的安装之配置可执行脚本
Arm common assembly instructions
常用网站汇总
leetcode刷题之整数加一









