我已经多次使用Zend_Db_Table更新,但这次我遇到了问题。我不知道为什么,所以请告诉我我哪里做错了。
$where = $directory->getAdapter()->quoteInto('id = ?', $id);
$total_votes = array('total_votes' => '(total_votes + 1)');
$directory->update($total_votes, $where);
/// $directory is a db table variable.
它不会更新数据库中的值。我使用探查器打印了查询:
**UPDATE dealers_directory SET `total_votes` = ? WHERE (`id` = 3)**
我不明白为什么它添加"?"而不是(total_votes + 1)。我已经在同一应用程序的几个地方使用了它,它工作正常,但我不知道这里有什么问题。
谢谢。
使用 new Zend_Db_Expr('(total_votes + 1)')
.