问题
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