0
votes

I am trying to figure out how to update multiple row in one update() in zend framework.

I have an array of IDs named ids and I would like to update one field of all the rows of these ids.

I tried to create a where condition like that :

$where = Bootstrap::$db->quoteInto('id_task IN (?)', $ids);

And then call the update method :

$this->getDbTable()->update(array("deleted" => 1), $where);

But I have a Syntax error or access violation error and my query looks like this in the debug output :

array(2) {
            [0]=>
            &string(54) "UPDATE `tasks` SET `deleted` = ? WHERE (id_task IN ())"
            [1]=>
            &array(1) {
              [0]=>
              int(1)
            }
          }

Does anyone know how to pass an array in the where condition of an update?

1
Right before $where = Bootstrap::$db..., what does var_dump($ids); show? - drew010
will the IN operator even work in UPDATE? Maybe try it as a Zend_Db_Expression instead of quoteInto() - RockyFord

1 Answers

0
votes

Maybe this way:

$where = Bootstrap::$db->quoteInto('id_task IN (?)', implode( ',', $ids ) );

Suppose your ids are integers and have been validated.