DQL Query fails
Asked Answered
A

2

7

I've got 2 tables in an MySQL DB, im using doctrine 1.2 and symfony 1.4.4

Installedbase and Spare

Installedbase:
ib_id
app_id
location

and

Spare:
spare_id
app_id
amount

Now i want to join the to tables to show how many of the app are in the spare.

e.g.

$q = self::createQuery("l")
->select('i.*, s.*')
->from('InstalledBase i, Spare s')
->execute();

return $q;

Doctrine knows there is a relation between the tables on the app_id field but i get the error

500 | Internal Server Error | Doctrine_Hydrator_Exception 
"Spare" with an alias of "s" in your query does not reference the parent component it is related to.

yaml: http://pastey.net/137237 I cant figure this one out, does anybody know what doctrine is complaining about?

Aluminize answered 4/6, 2010 at 7:53 Comment(2)
Please edit your question and show us the relevant sections from your schema, including relations.Coelacanth
done pastey.net/137237Aluminize
J
4
->from('InstalledBase i, i.Spare s')

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

Do add some further criteria to this query not to return everything from both tables.

Jereme answered 4/6, 2010 at 9:2 Comment(0)
S
0

By the looks of it, you haven't told Doctrine that those 2 tables are related.

Sterigma answered 4/6, 2010 at 7:56 Comment(1)
In my schema.yml i've added a one to many relation on the both the app_id fields, so it should know.Aluminize

© 2022 - 2024 — McMap. All rights reserved.