0

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?

Olivier
  • 3,121
  • 2
  • 20
  • 28

1 Answers1

0

Maybe this way:

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

Suppose your ids are integers and have been validated.

zelibobla
  • 1,498
  • 1
  • 16
  • 23