1

I use the following code:

$str= array('createdid' => $creator_newid);  
$where = array();
$where['id IN']  = $instance_ids;
$this->_table->update($str, $where);

And here the $instance_ids contains set of string (that is 1, 2, 3, 4, 5, 6…) and I'm getting zend error.

How do I solve this?

2
  • As you mentioned, $instance_ids is a set of string, this might be the problem. Please check with an array. Commented May 29, 2014 at 10:55
  • yeah, got some alternative way, sending them in quotes ('1','2','3',...) and also changed the update statement.. thank you @Prava-MindfireSolutions Commented May 29, 2014 at 11:16

2 Answers 2

4

Use Zend_Db_Abstract methods like

public function updatestatus($updateAry,$id) {

            if(!empty($id)) {
                try{
                        $res = $this->getDbTable()->update($updateAry, array('user_id=?'=>$id));
                        if (false === $res) {
                            return 0;  // bool false returned, query failed
                        } else {
                            return 1;
                        }
                } catch (Zend_Exception $zex){}
            }
    }

here

$updateAry is the data you want to update.

array('user_id=?'=>$id) It is like were clause

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

Comments

1

Use the Zend_Db_Adapter methods

$str = array('createdid' => $creator_newid);  
$where = array(
    $this->_table->getAdapter()->quoteInto('id IN(?)', $instance_ids))
);
$this->_table->update($str, $where);

The adapter will carefully escape and quote params for you.

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.