cross posted your last posting, but you are correct there. On Thursday, 20 March 2014 22:00:07 UTC+1, Herman Peeren wrote: > > You have one Product for every X. So you have to add that Product to the > X. You would probably call that property of X $product. When you want to > know which Product that X has, you do $specificX->getProduct(). If you also > want to know what Info you have for that X you do a > $specificX->getProduct()->getInfo(). If you immediately want to gt the Info > for that X, you define a getInfo() method in X which retrieves > $this->getProduct()->getInfo(). No need to define the association of Info > directly to X. But if you realy want to define that relation, then it is > possible too of course: just define a $info property in X. No problem that > is uses the same foreign key. But redundant, as said. > > Probably easier to not talk about X, but give it a proper name. That makes > reasoning about your model easier. And maybe I just got the > ManyToOne/OneToMany the other way around, but the principle stays the same: > when you have an association with a Product, you can find the Info of that > Product too. Whether or not to eager or lazy load depends on how you need > the information; that is for later, when optimising the database-access. > First build a model and forget about the database. That is my advice. > > I'm out, go to a conference and be back next week (which is very busy > too). So I won't react the coming week or so. Nothing personal. > > On Thursday, 20 March 2014 21:35:32 UTC+1, Parsifal wrote: >> >> Please read my previous reply first. By eager load do you mean I should >> run DQL instead of find()? If yes, then how can I have the result as object >> since doctrine require to have Product entity as object that I can add a >> new record to X, as I cannot simply use: >> $this->productId = $blah; >> Should I use that object hydrator? >> So if I understood you correcly to solve this error I should use DQL >> joining Product-Info entities with that particular hydrator that returns >> the result as object? Is it the only way to solve the error however I don't >> need Info while adding a new row to db, the problem is that the same entity >> is used as ManyToOne to other two entities. >> >
-- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
