2012-05-16 3 views
-1

응용 프로그램의 다른 모듈이 업데이트됩니다. 내가 추가 $ id를 포함 시켰 제외하고 여기에Zend DB 업데이트가 게시되지 않는 이유는 무엇입니까?

, 내가 여기

public function SomeAction() 
{ 
    $mapper = new Application_Model_SomeMapper(); 
    $model = new Application_Model_SomeModel(); //getters and setters 

    // action body 
    $request = $this->getRequest(); 
    $data = $this->_request->getParams(); 
    $someId = $data['someid']; 

    $get = $mapper->find($someId, new Application_Model_SomeModel, true); //find the row by id, and return array 

/* 
instantiating a form object and adding "submit" 
*/ 
    $form = new Module_Form_FormName(); 
    $form->setAction("/module/controller/action/params/$someId"); 
    $form->setMethod('post'); 
    $form->setName('some_edit'); 

    $submit = $form->createElement('button', 'submit'); 
    $submit->setAttrib('ignore',true); 
    $submit->setLabel('Edit Something'); 
    $form->addElement($submit); 


if ($this->_request->isPost()) 
    { 
     if($form->isValid($request->getPost())) 
     { 
      $data = $this->_request->getPost(); 

      if(empty($data['some_id' ])) 
      { 
       $data['tier_models_id'] = NULL; 
      } 

      unset($data['submit']); 

      $setters = $model->setId($data['id']) 
          ->setField1($data['field_1']); 

      if ($mapper->save($someId, $setters)) 
      { 
       $this->_redirect("/index/");     
      } 
     }  
    } 


    $form->populate($tier); 
    $this->view->form = $get; 

} 

http://framework.zend.com/manual/en/learning.quickstart.create-model.html에서 발견, 행 세트를 업데이트 시도 모델 매퍼를 사용하고하는 것은, 매퍼을 저장 기능의 예입니다 매개 변수

public function save(Application_Model_Guestbook $guestbook) 
{ 
    $data = array(
     'email' => $guestbook->getEmail(), 
     'comment' => $guestbook->getComment(), 
     'created' => date('Y-m-d H:i:s'), 
    ); 

    if (null === ($id = $guestbook->getId())) { 
     unset($data['id']); 
     $this->getDbTable()->insert($data); 
    } else { 
     $this->getDbTable()->update($data, array('id = ?' => $id)); //not happening, although the 'id' is passed as a param 
    } 
} 

누락 된 것이 있습니까?

답변

0

이 대신

$where = $this->getDbTable()->getAdapter()->quoteInto('id = ?', $id); 
$this->getDbTable()->update($data, $where); 
+0

입력 유형은 "버튼을", 그리고 일 "제출"할 필요가보십시오. – parseMaestro63

관련 문제