SqlDataProvider attribute null

I use SqlDataProvider to get mysql data

‘SELECT * FROM tableA LEFT OUTER JOIN tableB ON tableA.client_id = tableB.id’

tableA and tableB has the same column ‘id’ and ‘code’

I found column ‘id’ and ‘code’ is null when i use var_dump($models) in SqlDataProvider’s method ‘prepareKeys’

I use SqlDataProvider as gridview provider, so i need use attribute as DataColumn, but i can’t get ‘id’ and ‘code’ column data

following method is useless too

‘SELECT * FROM tableA AS A LEFT OUTER JOIN tableB AS B ON A.client_id = B.id’

if you have duplicate columns you need to alias them


SELECT table_a.*, table_b.id as bid, table_b.code as bcode FROM table_a LEFT OUTER JOIN table_b ON table_a.client_id = table_b.id