What goes wrong in the RSM-Builder you use: the columnname word_id (from 
the second use of the word-table) is replaced by the column_name 
traslation_id, but that columnname already exists. The RSM-Builder gives 
all fields back, also the ones that are not explicitly listed in the 
SELECT. Not tested, but I think giving it another name than translation_id 
would solve that problem. Not tested, but my guess after seeing that table 
layout.


On Tuesday, 4 March 2014 00:44:28 UTC+1, martijn korse wrote:
>
>
> On Saturday, March 1, 2014 4:26:13 PM UTC+1, Herman Peeren wrote:
>>
>> About the second part of your question:
>>
>> http://www.doctrine-project.org/api/orm/2.4/class-Doctrine.ORM.Query.ResultSetMapping.html#_addFieldResult
>> says that the 2nd parameter of addFieldResult( ) = $columnName = The name 
>> of the column in the SQL result set 
>> and the 3rd parameter = $fieldName = The name of the field on the 
>> declaring class. 
>> So: the *word_id* in "$rsm->addFieldResult('t', 'translation_id', 
>> 'word_id');" is the *field name* of the Words-entity, *not the column 
>> name* of the words-table.
>> Is that the case or did you happen to name that field something like 
>> *$wordId*?
>>
>
> Ah, you're right ... of course that should be wordId.
> I'm still struggling to get the right output though. I'm not sure how to 
> proceed and make it output both the word and the translation. But i guess i 
> better put that in a new topic if i don't figure it out.
>
> Still wondering what i'm doing wrong with the ResultSetMappingBuilder 
> though, as that seemed a lot easier than manually doing everything.
>  
>
>>
>> Still puzzling about the first part of your question with the 
>> ResultSetMappingBuilder.
>>
>
> What exactly is puzzling you? Did i not explain it well enough?
> I'd be happy to provide more/better information.
>
> My tables are as follows (in a simplified way):
>
> words
> ---------
> word_id
> word
> wordtype_id
>
> wordtypes
> --------------
> wordtype_id
> wordtype
>
> word_translations
> -------------------------
> translation_id
> originalword_id
> translationword_id
>
> a word has a certain type (verb, noun, etc) and it has translations, which 
> are defined by means of the word_translations table (n:n)
>
> With my query (that i put in my first post) i want to select a single word 
> with 1 translation.
>  
>

-- 
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/groups/opt_out.

Reply via email to