How to check existence of model in DB?
In Yii 1 version it was so
User::model()->exist()
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
In Yii2 you can add
exists()
to your query chain:(The generated SQL looks like this:
SELECT 1 FROM `tbl_user` WHERE `id`=1
.)Here is
Query->exists()
from Yii2 source:http://yii2ideas.blogspot.in/2017/06/yii2-database-operations.html