Zend Framework复合主键更新

时间:2010-08-30 10:28:06

标签: php zend-framework zend-db

对于项目,我需要更新PK包含两列的行。

起初我以为我应该这样做,但它给了我错误。有解决方案的人吗?

$data = array('foo','bar');
$where = $this->_getGateway()->getAdapter()
                    ->quoteInto(array('customerId=?','date=?'), array($comment->customerId, $comment->date));
$this->_getGateway()->update($data, $where);

由于

1 个答案:

答案 0 :(得分:2)

知道了!

$whereId = $this->_getGateway()->getAdapter()->quoteInto('customerId=?', $comment->customerId);
$whereDate = $this->_getGateway()->getAdapter()->quoteInto('date=?', $comment->date);
$this->_getGateway()->update($data, array($whereId, $whereDate));