php - Laravel 查询生成器不返回数据
问题描述
我有一个查询生成器,由于某种原因,即使表中有数据,它也会返回 null,我已经通过获取查询生成器生成的 sql 并在 HeidiSQL 中运行它来确认这一点,并且确实有数据。
以下是代码:
$billSource = DB::table('trea.audit_bill_master')
->select('source')
->where('fin_year', $fin_year)
->where('bill_no', $val)
->where('trea_code', $trea_code)
->first();
这是生成的SQL:
array:1 [
0 => array:3 [
"query" => "select "source" from "trea"."audit_bill_master" where "fin_year" = ? and "bill_no" = ? and "trea_code" = ? limit 1"
"bindings" => array:3 [
0 => "2021-2022"
1 => "146"
2 => "20"
]
"time" => 1.14
]
]
我使用 postgres 9.3 作为我的数据库和 laravel 5.8 版
解决方案
推荐阅读
- ios - iPad UITableView 重新加载缓慢
- sql - BASH 脚本中的 SQL 查询
- react-native - 在 Electron + React Native 项目中设置 keep_fnames
- java - MainActivity 应在启动画面期间加载
- java - 此代码中显示(“;”预期)错误的问题是什么。PS:我是初学者
- excel - VBA将行复制到其他工作表中的空行
- python - Tkinter 新窗口
- sql - 数据库设计 - 类别-对象关系
- javascript - React - 刷新页面后不显示所选值
- angular - Mat 扩展面板扩展到其他 html 元素