【发布时间】:2011-08-19 14:21:41
【问题描述】:
我正在尝试使用 URL 中的两个项目检索内容。这是应该执行此操作的 php/symfony 代码:
$em = $this->getDoctrine()->getEntityManager();
$repository = $this->getDoctrine()
->getRepository('ShoutMainBundle:Content');
$query = $repository->createQueryBuilder('p')
->where('p.slug > :slug')
->andWhere('p.subtocontentid > :parent')
->setParameters(array(
'slug' => $slug,
'parent' => $page
))
->getQuery();
$content = $query->getSingleResult();
但是,当执行此代码时,它会返回以下错误:
虽然预期至少有一行,但未找到查询结果。
我做了一些测试,$slug 和$page 变量中保存的数据包含正确的信息。我还测试了 MySQL 查询,查询得到了想要的结果,这让我更加困惑。
我错过了什么吗?
【问题讨论】:
标签: mysql doctrine doctrine-orm symfony