Use CONCAT in ActiveQuery

I use some Querys for filling my DropDownList:


$select = Checkliste::find()->select("CONCAT(number,': ',name) AS number_name")->where('active = 1')->asArray()->all();	

But the CONCAT doesn’t work:


The SQL being executed was: SELECT CONCAT(number, `': '`, `name)` AS `number_name` FROM `checklisten` WHERE active = 1

Is there some trick to solve this? I’m migrating yii to yii2, and in yii1 I used this method, but it doesn’t work any more…

Thanks!

Oh, I managed it by myself:


select(['id', 'CONCAT(number,\': \',name) AS number_name'])

But very sad, the old method doesn’t work any more…

2 Likes