Could you please also tell what version of Doctrine ORM you are using? It
may be caused by some wrong merge.
Anyway, your approach is basically incorrect, you should instead do
`->andWhere('vb.name LIKE :nameParameter')->setParameter('nameParameter',
'%' . $name . '%')`, which is much safer, uses query cache and avoids SQL
injections.
> --
> You received this message because you are subscribed to the Google Groups
> "doctrine-dev" group.
> To post to this group, send an email to doctrine-dev@googlegroups.com.
> To unsubscribe from this group, send email to
> doctrine-dev+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/doctrine-dev?hl=en-GB.
On Sat, Apr 28, 2012 at 3:14 PM, Marco Pivetta <ocram...@gmail.com> wrote:
> Hi there!
> Could you please also tell what version of Doctrine ORM you are using? It
> may be caused by some wrong merge.
> Anyway, your approach is basically incorrect, you should instead do
> `->andWhere('vb.name LIKE :nameParameter')->setParameter('nameParameter',
> '%' . $name . '%')`, which is much safer, uses query cache and avoids SQL
> injections.
>> --
>> You received this message because you are subscribed to the Google Groups
>> "doctrine-dev" group.
>> To post to this group, send an email to doctrine-dev@googlegroups.com.
>> To unsubscribe from this group, send email to
>> doctrine-dev+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/doctrine-dev?hl=en-GB.
> --
> You received this message because you are subscribed to the Google Groups
> "doctrine-dev" group.
> To post to this group, send an email to doctrine-dev@googlegroups.com.
> To unsubscribe from this group, send email to
> doctrine-dev+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/doctrine-dev?hl=en-GB.
Gennay: do _NOT_ use that method! That is just wrong and unsafe!
$qb->andWhere('vb.name LIKE :nameParam')->setParameter('nameParam',
$this->_request->getPost('name')); works just fine! Don't use what you
wrote!
Marco Pivetta
> Thank you all!
> I'm using Doctrine 2. For MySQL, I found another solution
> $name = str_replace("'", "''", $this->_request->getPost('name'));
> $qb->andWhere('vb.name like \'%'.$name.'%\'');
> this work. But I think the decision Marco is more correct for future
> use.
> Developers can think about the internal escaping for security purpose.
> --
> You received this message because you are subscribed to the Google Groups
> "doctrine-dev" group.
> To post to this group, send an email to doctrine-dev@googlegroups.com.
> To unsubscribe from this group, send email to
> doctrine-dev+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/doctrine-dev?hl=en-GB.
Gennay, I'm only iterating what Marco said. Don't use that implementation.
Doctrine sits on top of PDO which handles all your escaping for you. Using
that implementation is dangerous.
On Thu, May 3, 2012 at 8:16 AM, Marco Pivetta <ocram...@gmail.com> wrote:
> Gennay: do _NOT_ use that method! That is just wrong and unsafe!
> $qb->andWhere('vb.name LIKE :nameParam')->setParameter('nameParam',
> $this->_request->getPost('name')); works just fine! Don't use what you
> wrote!
> On 3 May 2012 08:30, Gennady <gennady...@gmail.com> wrote:
>> Thank you all!
>> I'm using Doctrine 2. For MySQL, I found another solution
>> $name = str_replace("'", "''", $this->_request->getPost('name'));
>> $qb->andWhere('vb.name like \'%'.$name.'%\'');
>> this work. But I think the decision Marco is more correct for future
>> use.
>> Developers can think about the internal escaping for security purpose.
>> --
>> You received this message because you are subscribed to the Google Groups
>> "doctrine-dev" group.
>> To post to this group, send an email to doctrine-dev@googlegroups.com.
>> To unsubscribe from this group, send email to
>> doctrine-dev+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/doctrine-dev?hl=en-GB.
> --
> You received this message because you are subscribed to the Google Groups
> "doctrine-dev" group.
> To post to this group, send an email to doctrine-dev@googlegroups.com.
> To unsubscribe from this group, send email to
> doctrine-dev+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/doctrine-dev?hl=en-GB.
> Gennay, I'm only iterating what Marco said. Don't use that implementation.
> Doctrine sits on top of PDO which handles all your escaping for you. Using
> that implementation is dangerous.
> Lee
> On Thu, May 3, 2012 at 8:16 AM, Marco Pivetta <ocram...@gmail.com> wrote:
> > Gennay: do _NOT_ use that method! That is just wrong and unsafe!
> > $qb->andWhere('vb.name LIKE :nameParam')->setParameter('nameParam',
> > $this->_request->getPost('name')); works just fine! Don't use what you
> > wrote!
> >> this work. But I think the decision Marco is more correct for future
> >> use.
> >> Developers can think about the internal escaping for security purpose.
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "doctrine-dev" group.
> >> To post to this group, send an email to doctrine-dev@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> doctrine-dev+unsubscribe@googlegroups.com.
> >> For more options, visit this group at
> >>http://groups.google.com/group/doctrine-dev?hl=en-GB.
> > --
> > You received this message because you are subscribed to the Google Groups
> > "doctrine-dev" group.
> > To post to this group, send an email to doctrine-dev@googlegroups.com.
> > To unsubscribe from this group, send email to
> > doctrine-dev+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/doctrine-dev?hl=en-GB.