メインコンテンツまでスキップ
Version: Fegg 5.x(開発版)

Model::whereBetween

Match a range of values

Description​

public self Model::whereBetween( string $column, mixed $from, mixed $to, [ string $andOr = 'AND' ] )

Adds column BETWEEN ? AND ?. Both ends are included. Throws InvalidArgumentException when $column is not a plain name.

Arguments​

NameData typeDefaultRemarks
$columnstringColumn name
$frommixedLowest value
$tomixedHighest value
$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',
));

// News of January 2026
// ... Where post_date BETWEEN '2026-01-01 00:00:00' AND '2026-01-31 23:59:59' AND ...
$records = $model->whereBetween('post_date', '2026-01-01 00:00:00', '2026-01-31 23:59:59')->find();