Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php DBTable创建新行,而不是关闭现有行的更新_Php_Zend Framework_Zend Db - Fatal编程技术网

Php DBTable创建新行,而不是关闭现有行的更新

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()方

我尝试使用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()方法返回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”,请在上面代码的第一行中将其更改为合适的值