Just using ?
would make multiple parameters be indexed in that order, whereas explicitly defining the index with ?1
would allow you to number the parameters in any order.
$qb->add('select', 'u')
->add('from', 'User u')
->add('where', $qb->expr()->orx(
$qb->expr()->eq( 'u.id', '?2'), // using 2 before 1 because I can
$qb->expr()->like( 'u.nickname', '?1')
))
->add('orderBy', 'u.name ASC');
->setParameter(1, 'bob'); // bound to u.nickname
->setParameter(2, 100); // bound to u.id