I would like Yii2's Query Builder to return empty strings for null values.
The equivalent of this:
IFNULL(Table.Column1, '')
In this:
$rows = (new \yii\db\Query())
->select(['Column1', 'Column2'])
->from('Table')
->all();
I would like Yii2's Query Builder to return empty strings for null values.
The equivalent of this:
IFNULL(Table.Column1, '')
In this:
$rows = (new \yii\db\Query())
->select(['Column1', 'Column2'])
->from('Table')
->all();
You can use this way
You can specify columns to be selected in either an array or a string, like the following. http://www.yiiframework.com/doc-2.0/yii-db-query.html#select()-detail
$rows = (new \yii\db\Query())
->select([" IFNULL(Column1,''), Column2 "])
->from('Table')
->all();
or
$rows = (new \yii\db\Query())
->select([" IFNULL(Column1,'')", Column2])
->from('Table')
->all();