getArrayResult on entity with ManyToOne association

前端 未结 2 1301
南旧
南旧 2021-01-17 18:33

Having the follow basic tables (one-to-many relationship)
Client - Has many users.
Users - Each user belongs to single client.

In a very simple exampl

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-17 19:24

    As far as I know, you can't do this, because ClientID is not a property of User. User has a property like $client, and that client entity has an $id.

    This is confusing you because you're dealing with Entites but you're still thinking in SQL.

    The solution, though slightly less efficient, would probably be to join the Client entity into your DQL query, and then get $results[N]['client']['id'] (or similar, I'm not too familiar with getResultArray())

提交回复
热议问题