我是新来的Zend框架,我试图更新数据库和网格中的数据,而不是更新特定的行所有的行都得到更新。请帮我解决一下这个。更新查询更新数据库中的所有行而不是特定行
这是我的控制器代码。
public function editAction()
{
$form = new Application_Form_user();
$this->view->form = $form;
if($this->getRequest()->isPost())
{
$formData= $this->getRequest()->getPost();
if($form->isvalid($formData))
{
$client= new Application_Model_DbTable_Client();
$firstname = $formData['firstname'];
$lastname = $formData['lastname'];
$email = $formData['email'];
$client->updateClient('Id',$firstname,$lastname,$email);
$this->_helper->redirector('index');
}
else
{
$form->populate($formData);
}
}
else
{
$id=$this->getRequest()->getparam('id');
if($id>0)
{
$client= new Application_Model_DbTable_Client();
$clients = $client->getClient('Id');
$form->populate($clients[0]);
}
}
}
这是我的型号代码。
public function updateClient($id,$firstname,$lastname,$email)
{
$data=array('firstname'=>$firstname,
'lastname'=>$lastname,
'email'=>$email);
$this->update($data,"Id=$id");
}
http://stackoverflow.com/questions/4097234/how-update-a-database-table-record-in-zend –