doctrine join without relation [duplicate]

梦想与她 提交于 2019-12-23 09:55:46

问题


Possible Duplicate:
Is this possible to join tables in doctrine ORM without using relations?

I have 2 classes Month and Vegetable. They don't have any relation together.

I would like to play the SQL : SELECT * FROM month, vegetable

In MySQL it works perfectly. I try it like that in Doctrine:

    $months = Doctrine_Query::create()
      ->select('m.*, v.*')
      ->from('month m, vegetable v')
      ->execute();

When I try it, I get :

"vegetable" with an alias of "v" in your query does not reference the parent component it is related to.

Does anyone know why ?

Is it possible to make what I want with doctrine ?


回答1:


First Doctrine is using DQl and not SQL.

DQL is using Objects, so Doctrine try to get a Relation from month to vegetable, but there isn't any relation.

When you want this to do with Doctrine, you must do two Queries and fetch them as Array and join them.



来源:https://stackoverflow.com/questions/5051912/doctrine-join-without-relation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!