开发者

zend framework update problem(update multiple rows)

开发者 https://www.devze.com 2022-12-30 05:19 出处:网络
i want to update multiple rows in DB using Zend Framework(Zend_db). i want to开发者_Python百科 add 2 to one field of each row

i want to update multiple rows in DB using Zend Framework(Zend_db). i want to开发者_Python百科 add 2 to one field of each row what should i use? im a beginner to ZF.


$row = array('theColumnName' => new Zend_Db_Expr('theColumnName + 2'));
$where = "id > 50"; 
// leave out the $where parameter to update all rows.
$nRowsUpdated = $db->update('tableName', $row, $where);

if you have multiple where conditions, you can do this:

$where = array();
$where[] = "foo = something";
$where[] = "id > something";

You should read the Zend_Db reference guide, which has plenty of examples.

0

精彩评论

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