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

Model::exists

条件に合う行があるかを確認します

説明​

public bool Model::exists()

条件に合う行が1つ以上あればtrueを返します。

例​

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

if ($model->where('title = ?', $title)->exists()) {
// a news with this title already exists
}