1、findOne()和findAll():
// 查询key值为10的客户 $customer = Customer::findOne(10); $customer = Customer::find()->where(['id' => 10])->one(); // 查询年龄为30,状态值为1的客户 $customer = Customer::findOne(['age' => 30, 'status' => 1]); $customer = Customer::find()->where(['age' => 30, 'status' => 1])->one(); // 查询key值为10的所有客户 $customers = Customer::findAll(10); $customers = Customer::find()->where(['id' => 10])->all(); // 查询key值为10,11,12的客户 $customers = Customer::findAll([10, 11, 12]); $customers = Customer::find()->where(['id' => [10, 11, 12]])->all(); // 查询年龄为30,状态值为1的所有客户 $customers = Customer::findAll(['age' => 30, 'status' => 1]); $customers = Customer::find()->where(['age' => 30, 'status' => 1])->all();