Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

doctrine join without relation [duplicate]

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 ?

like image 541
Charles Avatar asked Nov 05 '22 02:11

Charles


1 Answers

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.

like image 200
ridcully Avatar answered Nov 12 '22 10:11

ridcully