开发者

Zend Framework compound primary key update

开发者 https://www.devze.com 2023-01-14 07:11 出处:网络
For a project I need to update a row where the PK contains two columns. At first I thought I should do it like this but it gives me errors. Anybody with a solution?

For a project I need to update a row where the PK contains two columns.

At first I thought I should do it like this but it gives me errors. Anybody with a solution?

$data = array('foo','bar');
$where = $this->_getGateway()->getAdapter()
                    ->quoteI开发者_JAVA技巧nto(array('customerId=?','date=?'), array($comment->customerId, $comment->date));
$this->_getGateway()->update($data, $where);

Thanks


Got it!

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

精彩评论

暂无评论...
验证码 换一张
取 消