Wednesday 2 October 2013

Yii multiple update queries

Yii multiple update queries

below update query run in phpmyadmin. update all rows correctly.
SET @bal = 0;
UPDATE banking SET bank_bal = @bal := @bal + (cr_amt - dr_amt) WHERE
`bank_account_id` = 2
I tried above query in yii:
$update = Yii::app()->db->createCommand()
->update('banking',
array(
'bank_bal'=>new CDbExpression('@bal=0', array("@bal := @bal +
(cr_amt - dr_amt)"))
),
'bank_account_id=:id',
array(':id'=>$acc)
);
update balance column as 0 of all rows. I know @bal not set. where I put
this mysql line SET @bal = 0. Anybody can help.

No comments:

Post a Comment