Skip to main content
Version: Fegg 5.x (next)

Model::whereNotIn

Exclude a list of values

Description​

public self Model::whereNotIn( string $column, array $values, [ string $andOr = 'AND' ] )

Adds column NOT IN (?, ?, ...). An empty array excludes nothing (1 = 1). Throws InvalidArgumentException when $column is not a plain name.

Arguments​

NameData typeDefaultRemarks
$columnstringColumn name (news_id or cms_news.news_id)
$valuesarrayValues to exclude
$andOrstring'AND'How it joins the previous condition: AND or OR

Example​

Controller
$model = new Model(false, array(
'table' => 'cms_news',
'id' => 'news_id',
'visible' => 'visible',
));

// Other news than the current one
// ... Where news_id NOT IN (5) AND ...
$records = $model->whereNotIn('news_id', array(5))->order('post_date', 'desc')->limit(3)->all();