I need to use updateall to update position and column of widget
if (!empty($column3[0])) {
$column = preg_split("/,/", $column3[0]);
$name = $column[2];
switch ($name) {
case 'My Profile':
$table = 'WidgetProfile';
break;
case 'My script':
$table = 'WidgetScript';
break;
case 'My Setting':
$table = 'WidgetSetting';
break;
case 'Upload Script':
$table = 'WidgetUpload';
break;
case 'My message':
$table = 'WidgetMessages';
break;
default :
echo "Error3 0";
}
$this->loadModel($table);
$row = $this->$table->find('count',array('conditions'=>array('user_id'=>'$id));
if($row==0){
$this->$table->set(array('column',=> 3, 'position' => 1,'user_id'=>$id));
$this->$table->save();
}else{
$this->$table->updateAll(**?????????????**);
}
how to use updateAll for it
It’s not very clear from the question what you’re trying to do, but it looks like you’re trying to update an existing record, or if there isn’t a record already, create one. You can use
Model::save()for both. If the model’s id is set it will update, otherwise it’ll insert a new row.