Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Can query builder accept many many "WHERE"?

Can query builder accept many many "WHERE"? For example, can it work?

$builder->from('Robots')

foreach ($filter as $column => $value) {
    $builder->where("$column = $value");
}

Because I don't how many columns it the $filter



7.0k
Accepted
answer
edited Mar '16

Use this code, it will also prevent SQL injection

$builder->from('Robots')

foreach ($filter as $column => $value) {
    $builder->andWhere($column . ' = :' . $column ':', array($column => $value));
}

https://docs.phalconphp.com/en/latest/api/Phalcon%5Mvc%5Model%5Query%5Builder.html