3

I would like to do the follow query in Zend DB style. Basically i want to add 1000 to the value in my table where id = 1.

mysql_query("UPDATE `some_table` SET `value` = `value` + 1000 WHERE `id` = 1");

This is my Zend query, but it does not work

$data= array('value' => 'value'+1000);
$this->dbo->update('some_table', $data, $this->dbo->quoteInto('id = ?','1'));   

Advice appreciated.

1 Answer 1

8

Try this:

$data = array('value' => new Zend_Db_Expr('value + 1000'));
$this->dbo->update('some_table', $data, $this->dbo->quoteInto('id = ?', 1);

You need to use Zend_Db_Expr so that Zend_Db doesn't try to quote that value or apply any transformations to it.

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

Comments

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.