Selecting specific column value with condition
Try this:
$model = User::find()
->select('column1, column2')
->where(['id' => $id])
->one();
echo $model->column1;
Simply try:
$model = User::find()->select(['username','email'])->where('id=1')->One();
OR
$model = User::find()->select(['username','email'])->where('id=:id', [ ':id' => 1 ])->One();
Second way is more preferable.