Yii2: check exist ActiveRecord model in database

前端 未结 2 958
半阙折子戏
半阙折子戏 2021-01-03 19:45

How to check existence of model in DB? In Yii 1 version it was so User::model()->exist()

2条回答
  •  余生分开走
    2021-01-03 20:33

    if(Mastersettings::find()->where(['id'=>1,'status'=>1])->exists())
    {                    
      //....... Your code Here ......
    } 
    

    http://yii2ideas.blogspot.in/2017/06/yii2-database-operations.html

提交回复
热议问题