php - 调用字符串上的成员函数 where()
问题描述
我打算用laravel
框架开发网络。这是我的代码:
$valws = DB::table('layananpublik')->sum('value')->where('tahun',$tahun)->where('bulan',$stringbln)->where('kategori',$PilihKat);
我得到一个错误:
JobHarianController.php 第 195 行中的 FatalErrorException:调用字符串上的成员函数 where()
解决方案
尝试这个,
$valws = DB::table('layananpublik')
->where('tahun', '=',$tahun)
->where('bulan', '=',$stringbln)
->where('kategori', '=',$PilihKat)
->sum('value');
或者
$valws = DB::table('layananpublik')
->select(DB::raw("SUM(value) as value"))
->where('tahun', '=',$tahun)
->where('bulan', '=',$stringbln)
->where('kategori', '=',$PilihKat)
->get();
推荐阅读
- php - Laravel Policy 适用于 view 但不适用于 viewAny
- azure - 从逻辑应用中的 1 封电子邮件导入多个电子邮件附件
- linux - 如何检查 /tmp 和 /proc 文件系统是否安装在 chroot 环境中?
- javascript - 邮递员中的测试用例
- python - 有没有办法为每个打印的行填补缺失/空数据的空白,以确保所有数据的结构相似?
- javascript - 在每次输入后添加 1 个圆形/矩形,而不是在 JS 中一次添加 20 个
- mysql - Laravel - 如何使用子查询创建带有 where 子句的查询?
- mongodb - zsh(默认路径?)搞砸了 mongodb 安装
- android - 改造连接到不同的 URL 而不是基本 URL
- java - Mono.error 中的日志被输出两次