Orm querybuilder set parameters to collection
hey,
i have a new feature proposal for changing the method signature for Doctrine\ORM\QueryBuilder::setParameters from the array type from Doctrine ORM 2.x to the ArrayCollection with Parameter type of ORM 3.x
see https://github.com/doctrine/orm/pull/9490 see https://github.com/doctrine/orm/blob/3.0.x/UPGRADE.md#query-querybuilder-and-nativequery-parameters-bc-break
Hi.
I was about to get cracking on this and saw your PR @marcelthole :+1:
It would be nice if you could transform the following:
$params = ['name' => 'John'];
if ($someCondition) {
$qb->andWhere('age > :age');
$params['age'] = 18;
}
$qb->setParameters($params);
into
$params = new ArrayCollection([new Parameter('name', 'John')]);
if ($someCondition) {
$qb->andWhere('age > :age');
$params->add(new Parameter('age', 18));
}
$qb->setParameters($params);
@JoolsMcFly i like the idea and created a second PR for that here: https://github.com/rectorphp/rector-doctrine/pull/346 if this one gets merged we could check the addition :)
I think this one is good to go. What do you think @samsonasik ?
Thanks + thank you @marcelthole