Pages::setWhere($field[,$operator],$value)

Version 2019.1

Clear where and set new where clause to query

setWhere() uses same parameters as Pages::addWhere() but clears previous where clauses for given field.

Return value

$this

Arguments

$field
Field name to search from
$operator
Query operator: =, !=, <, <=, >, >=, LIKE, NOT LIKE
Default: Fieldtype defines how to search
$value
Search criteria

Full documentation

Get newest 10 projects that are open and ordered in this month:

$Projects = $this->get('pages','project')
    ->addWhere('status', 'open')
    ->addWhere('order_date', 'This month')
    ->setOrder('order_date','newest')
    ->setLimit(10);

Instead, get newest 10 that are closed:

$Projects->setWhere('status','closed');