i have a little problem with some database i created and i need a little help.
i have 3 tables: Users, Fruits and Transactions every user has many fruits and many transactions, every fruit have many transactions but every transaction just one fruit. this is the database model:
This way you can display which fruit got ordered by which owner it in grid form:
<?php
widget('zii.widgets.grid.CGridView', array(
//It is important to note, that if the Table/Model Primary Key is not "id" you have to
//define the CArrayDataProvider's "keyField" with the Primary Key label of that Table/Model.
'dataProvider' => new CArrayDataProvider($fruitModel->transactions, array('keyField'=>'ID')),
'columns' => array(
array('header'=>'Fruit', 'value'=>'$data->fruits->fruitName'),
array('header'=>'User', 'value'=>'$data->users->userName'),
),
));
?>
Hope that helps.
I written it up in a post that you responded to here.
I also have a more detialed version that I have written up on my blog here.
You are amazing!! thank you so much! this works and because i have two different AR i found cool solution because of you this is my fixed code:(all the relation in the user AR)