Find * and some additinal columns

Is there a way to select * and some extra columns without enumerating them all in ‘select’ parameter

of scopes or relations definition?

Something like

'select'=>array('*','concat_ws("field_1","field_2") as extra_col')

I think this should work, although it’s highly likely Yii already merges all fields indicated for selection. Make sure you have extra_col defined in model as public property.

So do I, but instead receive CDbException with message

Active record "SomeModel" is trying to select an invalid column "*". Note, the column must exist in the table or be an expression with alias.


Then just leave ‘*’ out and see what happens. Yii probably concatenates the selected fields from all input (like criteria, scope, default scope, relations, etc.).

There are two possible ways in this case, with different results:

First one


causes same error as above

and this one


works predictably fine (this is default value for ‘select’ option)

Try this :

$criteria->select = array_merge(Somemodel::model()->tableSchema->getColumnNames(),array(‘extra field1’,‘extra field2’))

Thanks for advice, my decision based on array_merge() too.