I've got a table with bunch of per-user configurations and each row contains user id, name of config, value of config 11 rows per user. Now when I try to update existing records I get +11 duplicate rows instead. Here is my update action:
public function updateAction($uid)
{
if ($this->request->isPost()) {
foreach ($this->request->getPost() as $name => $value) {
$config = Configs::findFirst("user_id = '".$uid."' AND name = '".$name."'");
$config->name = $name;
$config->value = $value;
$config->user_id = $uid;
$config->update();
}
$this->dispatcher->forward(array(
'controller' => 'config',
'action' => 'index'
));
}
}