Hi first a sidenote: you are using setId() which is deprecated.Should be replaced with
$this->audit->id = $_POST["oid"]; Then I'm not sure of your vision of the issue. I think you the edit function should always receive $id as parameter, and modify the row corresponding to that id only. This way the $id can't be changed only the corresponding value. I my scripts I even merged add() and edit() in edit($id = "") and my way to make the difference between adding and editing is to check weather $id is empty or not. olivvv [EMAIL PROTECTED] wrote: > Thanks again > > Haha... > I make it! > I use the model->db->update method: > > first I construct parmaters for 'update', > $fields=array(); > foreach (($this->params['data']['audit']) as $k => $v) > //$this->params['data']['audit'] is the post form data for table > 'audit' > { > if ($this->audit->hasField($k) && > !array_key_exists($k, > $fields))//use model->hasField to check fileds, > { > $fields[] = $k; > //the fields saved > $values[] = htmlspecialchars($v); > // > } > > } > $this->audit->setId($_POST["oid"]);//$_POST["oid"] is > the origin > PK's value. > > if($this->audit->hasAny($this->audit->primaryKey."='".$this->audit->id."'")){//if > the PK value is exists in database > if($this->audit->db->update($this->audit, $fields, > $values)){ > $this->set("ajaxsubscr","<script > language=\"javascript\">new > Ajax.Updater('ajax_update','/audit/index'+qstr+'', > {onComplete:function(request){Effect.Fade('".$this->action."_audit');stripe();initDrag();},asynchronous:true,evalScripts:true});</script>");//ajax > update,update audit list > } > } > $this->render('posterror'); //do something > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~----------~----~----~----~------~----~------~--~---