首页 > 解决方案 > 来自存储库的 findBy 触发内部错误但不是本地错误

问题描述

我对这个很迷茫......我不知道可能出了什么问题。

我有这段代码,它只是从一个地方查找所有消息。如您所见,该地点不能为空。

在开发模式下,我没有错误。在 prod 模式下,findBy 会触发内部错误。我确定就是这样,因为我可以进入第一个评论的 Json 返回而没有错误,但我无法到达第二个。

我也确定错误出现在 findBy 而不是存储库上,因为我试图分成两行并且 getRepository 没有错误。

    if (!isset($place)) {
        return new JsonResponse([
            'success' => false,
            'message' => "Place invalide"
        ]);
    }
    /*return new JsonResponse([
        'success' => false,
        'message' => "test0",
    ]);*/

    $messages_place = $em->getRepository('AppBundle:MessagePlace')->findBy(array('idPlace' =>$place));
    return new JsonResponse([
        'success' => false,
        'message' => "test",
    ]);

在我的 MessagePlace 实体中,我有

/**
 * @var \AppBundle\Entity\Place
 *
 * @ORM\ManyToOne(targetEntity="Place")
 * @ORM\JoinColumns({
 *   @ORM\JoinColumn(name="id_place", referencedColumnName="id")
 * })
 */
private $idPlace;

我不明白为什么这段代码会在服务器上触发错误 500,但不会在 localhost 中触发。

感谢你的协助。

编辑:我的坏问题解决了,我在 MessagePlace 中有一个错字问题,我查询的是 id_image 而不是 is_image ...对不起。

标签: phpsymfony

解决方案


“如您所见,这个地方不能为空。” “可空”设置的 JoinColumn 默认值为 true,因此它可以为空。

https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/annotations-reference.html#annref_joincolumn


推荐阅读