【问题标题】:Doctrine - DQL select query error with FKs even with IDENTITYDoctrine - 即使使用 IDENTITY,FK 也会出现 DQL 选择查询错误
【发布时间】:2015-06-01 22:09:29
【问题描述】:

我有一个应该返回 FK 的 DQL 查询。但是,即使使用 IDENTITY,我也遇到了查询错误。

我的实体字段:

//Profile.php
/**
 * @ORM\OneToMany(targetEntity="\Gabrieljmj\ProfileBundle\Entity\Website\Website", mappedBy="profile", cascade={"remove", "persist"})
 */
private $websites;

//Website.php
/**
 * @ORM\ManyToOne(targetEntity="\Gabrieljmj\ProfileBundle\Entity\Profile", inversedBy="websites")
 * @ORM\JoinColumn(name="p_id", referencedColumnName="id")
 */
private $profile;

我的 DQL:

SELECT IDENTITY(p.websites)
FROM   ProfileBundle:Profile AS p
WHERE  p.u_id = :u_id

还有错误:

[Semantical Error] line 0, col 18 near 'websites) ':错误:无效的路径表达式。必须是 SingleValuedAssociationField。

我无法提供更多细节,因为这就是我所知道的全部。我搜索了类似的问题,但他们都没有使用 IDENTITY(这是他们的问题)。

【问题讨论】:

    标签: php symfony doctrine dql


    【解决方案1】:

    尝试加入。像这样的

    SELECT p, w FROM ProfileBundle:Profile p JOIN p.websites w
    

    【讨论】:

    • 没有办法只获取网站?我不想要不必要的信息
    猜你喜欢
    • 2020-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-02
    • 2021-01-02
    • 2021-05-23
    • 1970-01-01
    • 2013-04-23
    相关资源
    最近更新 更多