Yii Relation Between 3 Models

budget_source

===============

source_id (PK)

amount

date_created

cash_advance

===============

ca_id (PK)

source_id (FK)

amount

date_created

expenses

===============

exp_id (PK)

ca_id (FK)

amount

date_created


relation


"budget_source" has many "cash_advance"

"cash_advanve" has many "expenes"

heres i want output query:




============================================================================

|Month   | Year |amount_budget_source|amount_cash_advance| amount_expenses |

============================================================================

|January | 2013 |100,000             |90,0000            |50,000           |

|Febuary | 2013 |100,000             |90,0000            |50,000           |

and display in ActiveHighcharts…

where can set my relation? in cash_advance model or budget_source model?

and how it would be realation?

Anyone can help me in relation

thanks in advance

Reinahrd

If you set the constraints in your database and then generate model with gii, the relations will be created in the right place (in all tables i think), one in "has many" and "belongs to" in the other table.

Edit: and use STAT relations pour amounts.