Find single record based on id.
$model = User::findOne($id);
Select single column based on id.
$model = User::findOne($id)->name;
Retrieve the single record from the database based on condition.
$model = User::find()->one(); // give first record
$model = User::find()->where(['id' => 2])->one(); // give single record based on id
Select single columns record from the database based on condition.
$model = User::find()->select('name,email_id')->where(['id' => 1])->one();
OR
$model = User::find()->select(['id','name','email_id'])->where(['id' => 1])->one();
OrderBy
$model = User::find()->select(['id','name','email_id'])->orderBy(['id' => SORT_DESC])->one();
OR
$model = User::find()->select(['id','name','email_id'])->orderBy(['id' => SORT_ASC])->one();