Documentation states:
class Cart
{
// ...
/**
* @OneToOne(targetEntity="Customer", inversedBy="cart")
* @JoinColumn(name="customer_id", referencedColumnName="id")
*/
private $customer;
// ...
}
This annotation represents such sql:
JOIN Customer c ON c.id = cart.customer_id
And the issue is that I need to add additional comparison there, like:
JOIN Customer c ON c.id = cart.customer_id AND c.anotherField = <constant>
Any solutions for that?
UPD:
the real additional condition I need for now is <const> BETWEEN c.f1 AND c.f2
you can use the
WITHkeyword to specify additional join conditions, as you can see in some of the examples.i think this should get you going:
i removed the
ONclause because i think there’s no need to explicitly specify the join’sONfields unless they are not the “standard” ones (id of each entity)also notice the call to
CURRENT_TIMESTAMP()which translates into MySQL’sNOW(). check out a list of other pretty useful aggregate functions and expresions here