How To Calculate 2 Models Or More In Yii ?

hello all,

i’m new in yii, on my last post, i have learn how to get data from two model in one form, now, i getting curious how to use calculation method within two tables in yii,

for example :

i got 2 tables,

assumption

asmp_id --> PK

asmp_name

asmp_score

cost_variable

var_id --> PK

var_name

var_score

var_qty

var_price

var_tot_price

each assumption (asmp_id) whenever it was selected by user, and according to user need, it could be calculate (+,-,*,/) with the selected value of cost_variable attributes,

for ex :

asmp_id = 1

asmp_name = discount

asmp_val = 25%

asmp_id = 2

asmp_name = tax_rate

asmp_val = 12%

var_id = 1

var_name = drilling machine

var_qty = 2

var_price = 800.000.000

var_tot_price = var_qty * var_price = 1.600.000.000

var_id = 2

var_name = cutting machine

var_qty = 2

var_price = 2.000.000.000

var_tot_price = var_qty * var_price = 4.000.000.000

var_id = 3

var_name = licensing

var_qty = 1

var_price = 150.000.000

var_tot_price = var_qty * var_price = 150.000.000

the question,

  1. is it possible for me, when i choose asmp_id = 1 then i need to multiplied it with the sum of (var_id =1 + var_id =2) ? ===> 25% * (1.600.000.000 + 4.000.000) and then the result i displayed the result in a form.

  2. meanwhile the first question, the asmp_id = 2 needed to calculate only with var_id = 3 (12% * 150.000.000)

  3. if that was possible, how could i do that in yii?

my best regards for all members here,

thx for the attention… :)

i forget, the user can determined by their selves what operation can they do to the var and assumption, this is where i really get interested in,

my thanks all