This my problem. News to me  
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/inheritance-mapping.html
Thanks for answering my questions.

Em segunda-feira, 24 de fevereiro de 2014 17h04min16s UTC-3, Herman Peeren 
escreveu:
>
> Please look at the documentation about *associations *and about *DQL*.
> Especially: 
> http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#joins
>
> *First *you define your entities. for instance: Usario, UsarioEndereco 
> and UsarioIdentidade (which would be something like: User, UserAddress and 
> UserProfile, if you would say it in English, which is not necessary at 
> all). Mind I used it in singular (Usario), although in your tables you use 
> plural. An entity is a singular thing. You can use different names for the 
> tables and for the entities: you have to map them anyway. 
>
> *Second *you define the associated fields and the mapping. For instance 
> in your Usario entity you can have a $enderecos-field, holding a collection 
> of addresses, with a OneToMany-mapping to your UsarioEndereco entity. And 
> let's say the UsarioIdentidade has a OneToOne association to Usario, using 
> a field $usario in UsarioIdentidade and a field $identidade in Usario.
>
> *Third*, the query. that would then be something like:
>
> $query->select('i','u', 'e')
>                 ->from('Rangos\Entity\usuariosIdentidade','i')
>                 ->join("i.usario", 'u' )
>                 ->join("u.enderecos", 'e')
>
> Or is the Usario used as parent-entity? In that case read the 
> documentation about inheritance:
>
> http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/inheritance-mapping.html
>
> Most important: you are not querying the tables with DQL, but the 
> entities! The entities (objects) form a network, the object graph. You can 
> "walk" that graph. The associations are not defined in the query (with ON 
> or WHERE), but in the mapping. That is the whole point of an ORM; otherwise 
> there is no need to use it and you could better just directly query the 
> database with SQL.
>
>
>
> On Monday, 24 February 2014 20:20:12 UTC+1, João Carlos Santa Ana wrote:
>>
>>         $query = $this->getEntityManager()->createQueryBuilder(); 
>>         $query->select('i','u', 'e')
>>                 ->from('Rangos\Entity\usuariosIdentidade','i')
>>                 ->innerJoin("i.userIUser", 'u')
>>                 ->join("Rangos\Entity\UsuariosEndereco", 'e')
>>                 ->where("e.userEndUser", 'u.userId');
>>                  $result = $query->getQuery()->execute();
>>
>> Em segunda-feira, 24 de fevereiro de 2014 16h19min12s UTC-3, João Carlos 
>> Santa Ana escreveu:
>>>
>>> OK, excuse my bad english. 
>>> But I need to bring several tables 1,2,3,4 with reference to a table. 
>>> Where tables 1,2,3,4 contains id of the reference table. 
>>> In DTL consulting encontri not this formula. can help an example? 
>>> thank you
>>>
>>> Em segunda-feira, 24 de fevereiro de 2014 15h57min44s UTC-3, Herman 
>>> Peeren escreveu:
>>>>
>>>> This mailing list is in English. Obrigado!
>>>>
>>>> What you are doing wrong here is: defining an ON-clause. That is how 
>>>> you'd do it in SQL. In DQL however you define the relationship between 
>>>> your 
>>>> entities in the mapping-information (via annotations, xml, yaml or php) 
>>>> and 
>>>> in the query you use that relationship. So: define a OneToOne, OneToMany, 
>>>> ManyToOne or ManyToMany relationship and use that in the query (and 
>>>> consequently no need to use a ON).
>>>>
>>>>
>>>> On Monday, 24 February 2014 19:46:41 UTC+1, João Carlos Santa Ana wrote:
>>>>>
>>>>> Alguém ajuda por favor.
>>>>>
>>>>> Tenho varias tabelas: endereco, identidade, cartao, contato, debitos 
>>>>> ....
>>>>> Todas com o id da tabela do usuario.
>>>>>
>>>>> preciso fazer uma consulta que traga todas as tabelas relacionadas de 
>>>>> uma vez.
>>>>>
>>>>> Tentei fazer uma consulta simples:
>>>>>
>>>>> $query = $this->em->createQuery("SELECT i, e FROM 
>>>>> R\Entity\UsuariosIdentidade as i "
>>>>>                    . " JOIN R\Entity\UsuariosEndereco as e ON 
>>>>> e.userEndUser = i.userIUser ");
>>>>>           $result = $query->getResult();
>>>>>
>>>>> Recebo este erro:
>>>>> OBS: SILEX
>>>>>
>>>>> QueryException: [Semantical Error] line 0, col 92 near 'as e ON 
>>>>> e.userEndUser': Error: Identification Variable R\Entity\UsuariosEndereco 
>>>>> used in join path expression but was not defined before.
>>>>>
>>>>> Alguem pode dar alguma direção do que devo fazer para conseguir uma 
>>>>> query que me traga todas as tabela seja com createQueryBuilder, 
>>>>> createQuery 
>>>>> ou  EntityRepository;
>>>>>
>>>>

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