メインコンテンツまでスキップ
Version: Fegg 5.x

Model::limit

行数を制限します

説明​

public self Model::limit( int $count, [ int $offset = 0 ] )

all、column、toSqlにLIMITを付けます。one、value、existsはオフセットを使います。countは無視します。findは代わりにlistMaxとcurrentでページングし、limit()を設定しているとLogicExceptionを投げます。

$countが1未満、または$offsetが0未満の場合はInvalidArgumentExceptionを投げます。

引数​

名前データ型デフォルト備考
$countint最大の行数
$offsetint0読み飛ばす行数

例​

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

// The 5 newest
$records = $model->order('post_date', 'desc')->limit(5)->all();

// The next 5 (rows 6 to 10)
$records = $model->order('post_date', 'desc')->limit(5, 5)->all();