Hi Felippe,

The criteria API currently doesn't support cross-association filtering.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On 27 August 2015 at 03:29, Felippe Rodrigo Puhle <[email protected]>
wrote:

> Hi! Considering two entities (with a ManyToOne relationship), is it
> possible to do something like this ?
>
>  *ENTITY: CLIENTE*
>
>> /**
>>  * @ORM\Table(name="cliente")
>>  * @ORM\Entity
>>  */
>> class Cliente {
>>     /**
>>      * @ORM\Column(name="id_cliente", type="integer")
>>      * @ORM\Id
>>      * @ORM\GeneratedValue(strategy="AUTO")
>>      */
>>     private $id;
>>     /**
>>      * @ORM\Column(type="string", length=50)
>>      */
>>     private $nome;
>>     // getters, setters, etc...
>> }
>
>
>
>  *ENTITY: PEDIDO*
>
>> /**
>>  * @ORM\Table(name="pedido")
>>  * @ORM\Entity
>>  */
>> class Pedido {
>>     /**
>>      * @ORM\Column(name="id_pedido", type="integer")
>>      * @ORM\Id
>>      * @ORM\GeneratedValue(strategy="AUTO")
>>      */
>>     private $id;
>>     /**
>>      * @ORM\ManyToOne(targetEntity="Cliente")
>>      * @ORM\JoinColumn(name="id_cliente",
>> referencedColumnName="id_cliente")
>>      */
>>     private $cliente;
>>     // getters, setters, etc...
>> }
>
>
>  *EXAMPLE QUERY*
>
>>         $criteria =
>> Criteria::create()->where(Criteria::expr()->contains('cliente.nome',
>> 'Felippe'));
>>         $pedidos =
>> $this->entityManager->getRepository('Admin\Models\Pedido')
>>                 ->matching($criteria);
>
>
> *ERROR MESSAGE:* Unrecognized field: cliente.nome
>
> I wrote a utility class to handle with jQuery Datatables search... And I'm
> trying to create a function on a Generic DAO to handle with it...
>
> Can anyone help me ?
>
> Thanks!
>
> --
> 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.
>

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

Reply via email to