Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine2 Query builder problem with like

I'm using this for in my doctrine2 query but it won't work

  $obj_query_builder->select('p')
   ->from('General\Domain\Product', 'p')
   ->where('p.cach_all_stop_words LIKE ?', '%avond%');

It must be this query:

SELECT * FROM `product` WHERE `cach_all_stop_words` LIKE '%avond%'

But there is an error in my query I think

like image 577
A Rozema Avatar asked Mar 09 '26 09:03

A Rozema


1 Answers

The QueryBuilder syntax in Doctrine 2 which is defined in http://www.doctrine-project.org/docs/orm/2.0/en/reference/query-builder.html is slightly different than the one you used in your query.

Can you try this query:

$obj_query_builder->add('select', 'p')
  ->add('from', 'General\Domain\Product p')
  ->add('where', 'p.cach_all_stop_words LIKE ?1')
  ->setParameter(1, '%avond%')

You can also see some other examples in the link I posted above.

EDIT: I saw below in the page in "Helper methods" that your syntax should also work. Try the query I wrote above.

like image 182
hdz200 Avatar answered Mar 11 '26 00:03

hdz200



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!