当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
C language structure specifying initialization
Scientists say Australian plan to cull up to 10,000 wild horses doesn’t go far enough
TypeScript(下)
浏览器工作原理与实践
Database programming of node
启用AHCI后无法启动系统
查漏补缺(九)---程序篇
手动实现简单的Promise及其基础功能
常用sql语句收藏
若依如何input改成文本
自用学习笔记-connectingString配置
Analysis of fixed point PID code of FOC motor Library
ES6的新特性
Devexpress Gridview 添加全选列
C# Task.Delay和Thread.Sleep的区别
【Markdown笔记】
excel里有文字的数字怎么从小到大排序,而不是首数字排序
EF CORE在ASP.NET CORE项目中基于数据库优先模式生成实体模型
file_get_contents 访问 ssl 错误的两种解决方法
Aperçu de Redux









