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

Model::count

Get the number of matching rows

Description​

public int Model::count()

Returns the number of matching rows. With group or having, it returns the number of groups. order and limit are ignored.

Example​

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

$count = $model->count();
// -> 23

$count = $model->where('category = ?', 2)->count();
// -> 7

// Number of categories
$count = $model->group('category')->count();
// -> 3