Help With Many To Many Relation

all,

i need to get a table value based on the primary key from it table then i used that on the other table,

i can ilustrate my question like this:

table a

id_a

att_a1

att_a2

att_a3

att_a4

att_a5

table b —>dummy table

id_a

id_c

table c ----> here i need to calulate myn result

id_c

att_c1 = att_a1*percentage_a1

percentage_a1

att_c2 = att_a2*percentage_a2

percentage_a2

att_c3 = att_c2+att_a4

how could i do that in yii?

any response pls,

thx,my regards