Php DBTable创建新行,而不是关闭现有行的更新
我尝试使用now数据更新DB条目,但我只是创建一个新条目:Php DBTable创建新行,而不是关闭现有行的更新,php,zend-framework,zend-db,Php,Zend Framework,Zend Db,我尝试使用now数据更新DB条目,但我只是创建一个新条目: $client =$this->clientTable->find($id); $client->CompanyName = $request->getPost('CompanyName'); $this->clientTable->update(); $this->_redirect('client/index'); Zend\u Db\u Table\u Abstract::find()方
$client =$this->clientTable->find($id);
$client->CompanyName = $request->getPost('CompanyName');
$this->clientTable->update();
$this->_redirect('client/index');
Zend\u Db\u Table\u Abstract::find()方法返回Zend\u Db\u Table\u行集对象。您应该使用将返回您的Zend_Db_Table_Row对象的方法并使用它 例如:
$clientRow = $this->clientTable->fetchRow(array('id' => $id));
$clientRow->CompanyName = $request->getPost('CompanyName');
$clientRow->save();
如果表的主键名称不是“id”,请在上面代码的第一行中将其更改为合适的值