0

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");
fpilee
  • 1,918
  • 2
  • 22
  • 38
  • 1
    try with `$qb->having("count(client.orders) <= :value");` – Matteo Apr 29 '17 at 19:16
  • This is the error, [Semantical Error] line 0, col 76 near 'orders) <= :value': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected. – fpilee Apr 29 '17 at 22:07

0 Answers0