parameters in clauses orWhere/andWhere

how I can pass parameters in clauses orWhere / andWhere, with query builder??

something like this:

$builder->andWhere( "filed LIKE ?", $value)

Pass bind params to execute method call

$result = $this->modelsManager->createBuilder()
   ->from('Mymodel')
   ->where('xxx = 1')
   ->andWhere('username = :name:')
   ->getQuery()
   ->exequte(array('name' => $value));


29.8k

thanks but i wanna use the LIKE operator, what is the sintax for that

...
   ->andWhere('filed LIKE :name:')
   ->getQuery()
   ->exequte(array('name' => $value));

use any sql you want, just place named parameters and then pass to exequte call array with keys as named parameters without : at start and end. So if you write

->where('xxx = :randomvar:')
->andWhere('filed LIKE :anotherrandomvar:')

then to exequte you pass it like this

->exequte(array('randomvar' => $value1, 'anotherrandomvar' => $value2));


29.8k

thanks!! one more question, if i wanna use the IN clausule, what is the sintax for that