Yii foreach 错误?

Yii foreach error?

我调用了一个函数。得到 table 数字 (result=0) 结果并更新相同的 table 值 0 到 1。我正在使用更新 query.i 有 运行 这个函数到 return 错误:: CDbCommand::update().

缺少参数 2
 public function newdisplaycontent()
{
    $count = Yii::app()->db->createCommand()
        ->select()
        ->from('scrolltable')
        ->where('result=:result', array(':result'=>0))
        ->queryAll();
$rs=array();
//print_r($count);

foreach($count as $item){
//process each item here
    $rs=$item['ID'];
    $user=Yii::app()->db->createCommand()
    ->update("scrolltable SET result = 1")
    ->where('ID=:id', array(':id'=>$rs));
}

return $rs;
}

感谢您的功能帮助..

update() 的正确语法如下:

$user=Yii::app()->db->createCommand()
->update("scrolltable",array("result" => "1"))
->where('ID=:id', array(':id'=>$rs));

作为官方文档:

update() Creates and executes an UPDATE SQL statement. The method will properly escape the column names and bind the values to be updated.

public integer update(string $table, array $columns, mixed $conditions='', array $params=array ( ))