1

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

1 Answer 1

1
$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.

Sign up to request clarification or add additional context in comments.

1 Comment

$row = array('theColumnName1' => new Zend_Db_Expr('theColumnName1 + 2') , 'theColumnName2' => new Zend_Db_Expr('theColumnName2 + 2')); $where = "condition1 and condition2"; is it right if i use that like this one?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.