php - findBy() 返回 null 但 db 已满
问题描述
我必须在需要比较两个 id 的地方建立 db 表。在表一中,我有 $id,在其他表中,我有 $previousId。
第一个表 id 由查询生成器找到,第二个我需要通过我设置的存储库找到。
每次我 dump() 结果时,即使我的数据库中有多个字段具有 previousId 值,它也会返回 [] 。
我的代码:
public function myMethod($previousId)
{
$tableOne = $this->getTableOneRepository()
->createQueryBuilder('e')
->select('e')
->getQuery()
->getResult();
$tableTwo = $this->getTableTwoRepository()->findBy(['previousId' => $previousId]);
dump(tableTwo);die; ----// returns [] even I if have table data
if($tableOne->getId() == $tableTwo->getPreviousId){
throw new \Exception('This message is already been archived.');
}
}
解决方案
推荐阅读
- c - 查找多嵌套数组的下一个内存变量
- go - 使用 viper 的动态组名
- sockets - 通过 Internet 在分布式系统中的 ZMQ 套接字之间进行通信
- c# - System.IO.FileNotFoundException:找不到文件
- php - 谷歌云存储 - API 不工作它只显示 index.php
- python - 如果我的行中的元素也为零,如何将我的整行设置为零?
- php - 想要使用 php 在 html 中显示 XML 视图
- c# - 通过 SharePoint 使用连续保存和版本控制开发文件格式
- spring - @WebFluxTest 与 Apache Freemarker 失败
- node.js - 弃用警告: timers.unenroll() 已弃用。请改用 clearTimeout