yii2 Active Record Find one record


Example

$customer = Customer::findOne(10);

or

$customer = Customer::find()->where(['id' => 10])->one();

or

$customer = Customer::find()->select('name,age')->where(['id' => 10])->one();

or

$customer = Customer::findOne(['age' => 30, 'status' => 1]);

or

$customer = Customer::find()->where(['age' => 30, 'status' => 1])->one();