/** * @param QueryBuilder * @param int * @param int */ private function configureUpdateQb(QueryBuilder $qb, $newPos, $oldPos) { $qb->update(); if ($newPos < $oldPos) { $shiftFrom = $newPos; $shiftTo = $oldPos - 1; $sign = '+'; } else { $shiftFrom = $oldPos + 1; $shiftTo = $newPos; $sign = '-'; } $qb->andWhere('e.position >= :from'); $qb->andWhere('e.position <= :to'); $qb->setParameter('from', $shiftFrom); $qb->setParameter('to', $shiftTo); $qb->set('e.position', "e.position {$sign} 1"); }