這個作品非常好:遞增與updateAll()列值的價值
$test = self::updateAll(
array('left_nr' => '3',
'right_nr' => '3',),
'left_nr>=:left_nr AND right_nr>=:right_nr',
array(
':left_nr' => $parent->left_nr,
':right_nr' => $parent->right_nr,
//':new_left_nr' => 'left_nr + 2',
//':new_right_nr' => 'right_nr + 2'
)
);
,但我要的是:
$test = self::updateAll(
array('left_nr' => ':new_left_nr',
'right_nr' => ':new_right_nr',),
'left_nr>=:left_nr AND right_nr>=:right_nr',
array(
':left_nr' => $parent->left_nr,
':right_nr' => $parent->right_nr,
':new_left_nr' => 'left_nr + 2',
':new_right_nr' => 'right_nr + 2'
)
);
當我嘗試代碼,我得到以下錯誤:
CDbCommand無法執行SQL語句:SQLSTATE [HY093]:無效的參數編號:綁定變量的數量與令牌數量不匹配。執行的SQL語句是:UPDATE test_nested_set
SET left_nr
=:YP0,right_nr
=:YP1 WHERE left_nr> =:left_nr和right_nr> =:right_nr
我怎樣才能實現呢?