如何在Zend中更新数据库表记录? [英] How update a database table record in Zend?
本文介绍了如何在Zend中更新数据库表记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用这样的select,并且它成功获取了记录:
I am using select like this and it is fetching record successfully:
$table = new Bugs();
$select = $table->select();
$select->where('bug_status = ?', 'NEW');
$rows = $table->fetchAll($select);
但是现在我想更新相同的记录.例如在简单的MySQL中.
But Now I want to update same record. For example in simple MySQL.
UPDATE TableName Set id='2' WHERE id='1';
如何在Zend中执行上述查询?
How to execute above query in Zend ?
谢谢
推荐答案
$data = array(
'field1' => 'value1',
'field2' => 'value2'
);
$where = $table->getAdapter()->quoteInto('id = ?', $id)
$table = new Table();
$table->update($data, $where);
这篇关于如何在Zend中更新数据库表记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文