"Обычный" LIKE:
User::find()->andWhere(['like', 'username', '89'])->all();
// SQL: `username` LIKE '89'
Левый/Правый/Обычный LIKE (осторожно, возможны
SQL-инъекции)
User::find()->andWhere(['like', 'username', '%89', false])->all();
User::find()->andWhere(['like', 'username', '89%', false])->all();
User::find()->andWhere(['like', 'username', '%89%', false])->all();
Левый/Правый/Обычный LIKE (Без SQL-инъекций, то есть входные значения $str будут обработаны )
User::find()->andWhere([new \yii\db\Expression('username LIKE :param', [':param' => '%' . $str]),])->all();
User::find()->andWhere([new \yii\db\Expression('username LIKE :param', [':param' => $str . '%']),])->all();
User::find()->andWhere([new \yii\db\Expression('username LIKE :param', [':param' => '%' . $str . '%']),])->all();