We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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));


36.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));


36.8k

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