开发者

How to make a nested query with an Entity that doesn't really exist (many-to-many)

I'm new with Doctrine2 so my question can be easy to answer (I hope so). First of all, here the SQL query that I'd w开发者_如何学运维ant :

SELECT * FROM Document WHERE id NOT IN (SELECT document_id FROM Documents_Folders)

Pretty simple isn't it ? The porblem is that my table 'Documents_Folders' is not an entity. In fact, it was create because I have a many-to-many relation between my entities 'Document' and 'Folder'.

I tried several queries, but none worked.

Thanks.


It really does look pretty simple, so it's not the problem with your SQL. So if you want some help, tell us what is the error that you get?

BTW Your database shouldn't care what you use Documents_Folders for - it's just a table. (I don't know Doctrine2, but it's still regular database underneath, isn't it?)


Out of curiosity, What is your business case here. Are you trying to get orphaned documents? A Document can be part of Many Folders and a Folder can have many Documents?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜