米
首页
心情
图集
所有
搜索
登录
tp6中case、when、else、end的用法
2021-04-26
54.78w热度
case、when、else、end是常见的操作,这里给一个demo ``` $res = Db::name("session_detail") ->alias("a") ->join("user_session b", "b.id = a.sess_id", "left") ->join("staff s", "b.cust_id = s.account", "left") ->join("user_info c", "b.u_cust_id = c.cust_id", "left") ->join("access acc", "b.access_id = acc.id", "left") ->join("robot r", "acc.robot_id = r.id", "left") ->where(["a.sess_id" => $id]) ->where("a.evaluate_msg_type", "IN", "(0, 8, 9, 100)") ->field("a.id as session_detail_id,a.content, a.state, a.msg_type, a.sess_id, a.create_time,a.msg_key,b.u_cust_id as to_id, CASE a.send_from WHEN 4 THEN acc.head_img WHEN 5 THEN r.img WHEN 1 THEN c.headimgurl WHEN 3 THEN c.headimgurl ELSE s.profile END headimgurl, CASE a.send_from WHEN 4 THEN '系统消息' WHEN 5 THEN r.name WHEN 1 THEN c.nickname WHEN 3 THEN c.nickname ELSE s.nickname END nickname, a.send_from, a.evaluate_msg_type ") ->select(); ```
注:原创不易,转载请注明出处(
https://micuu.com/new/1531.html
),本站所有资源来源于网络收集,如有侵权请联系QQ245557979进行清除。
最后修改与 2022-02-22
上一篇:
git常用命令,新建分期合并到dev分支
下一篇:
layui结合Vue使用,初始化layui.use解决办法
▶
珍藏视频
▶
10分钟高效燃脂
▶
30天高效瘦脸操
▶
5分钟缓解颈椎操
友人
→
微博
→
全民K歌
→
唱吧
→
今日头条
→
悠悠网
→
科技小锅盖
→
彼岸桌面
→
阮一峰
→
laravel社区
→
V2ex
→
掘金
+
更多