0

我正在尝试执行更新,但似乎没有任何效果。我想这与我的回调有关,因为当回调被禁用时更新效果很好。这是我的尝试块。

try{
      $updatestat=NULL;
      $updateresult=NULL;
      $id = Arr::get($_POST, 'id');

      $scode=trim(Arr::get($_POST, 'stationcode'));
      $sname=trim(Arr::get($_POST, 'stationname'));
      $dsupdate = new Model_Dstations($id);
      $dsupdate->scode = $scode;
      $dsupdate->sname = $sname;

      $validation = new Validation($_POST);          
  $validation->rule('scode', array($dsupdate, 'check_updatecheck' ), array( ':validation', ':value',':field',$id ));
      $validation->rule('sname', array($dsupdate, 'check_updatecheck' ), array( ':validation', ':value',':field',$id ));
      $result['sql']=$dsupdate->save($validation);}
4

1 回答 1

0

您的代码看起来一团糟。尝试这个:

  $dsupdate = new Model_Dstations($id);

  $validation = new Validation($_POST);          
  $validation->rule('scode', array($dsupdate, 'check_updatecheck' ), array( ':validation', ':value',':field',$id ));
  $validation->rule('sname', array($dsupdate, 'check_updatecheck' ), array( ':validation', ':value',':field',$id ));

  if ($validation->check()) {
      $dsupdate->scode = $scode;
      $dsupdate->sname = $sname;
      $dsupdate->save();
  }
于 2011-12-21T06:26:12.397 回答