Rename query keys in an array(while using a db query)

Is there a way to rename column names when using a db query?

Im using leftJoin with several tables which have a couple of same column names.

Is there a way to add a custom prefix per per array key? (no not looking for a way to manuplilate the array after the db query)

Changing the column names is not an option!

Example output




(

    [1]=>array(


                     product => name of product 

                     translation => naam van product


                     // the issue here (key is double)

                     translation => nombre del producto


                     )


)

???

Using MVC

in your Model your using dbQuery

in your Controller you create providers an giv this to a view

in a View you can use a widget

so in which place you want to change what?

in your Model an ActiveRecord look at attributLabels

My link

suppose you have a table name product which joins translation table, you can create alias for joined columns names like


new Query()

->select('p.translation, t.translation as foobar') // specify your columns you need changed

->from('product p')

->leftJoin('translation t', 't.product_id = p.id')->all();

Thanks this works :slight_smile: