I'm filtering a table of clients using doctrine query builder Client entity have a field $orders
/**
* Bidirectional - One-To-Many (INVERSE SIDE)
* @ORM\OneToMany(targetEntity="Orders", mappedBy="client", cascade={"persist"} )
*
*/
private $orders;
and Order entity have a field $client
/**
* @ORM\ManyToOne(targetEntity="Client", cascade="persist", inversedBy="orders")
* @ORM\JoinColumn(name="client", referencedColumnName="id", onDelete="SET NULL")
*
* */
private $client;
So in my Client repository I'm trying to select clients with less than or equal to a value.
$qb->andWhere("client.orders <= :value");
However I cannot access to the numbers of orders.
$qb->andWhere("count(client.orders) <= :value");
$qb->andWhere("client.orders.count <= :value");