I have to do a update query of 800k rows and looking for the best way to do this. All rows are updated with the same values excepted one field (D in my exemple). This field can be 1 or 0. I use update() methode of Zend_Db. I think about 3 methods to do this :
Methode 1 : Update each row, one after one (with a foreach).
Methode 2 : Do an IF in the update to set the value of the field
Methode 3 : Divide rows in two groups (one with field = 1 and another with field = 0) and make two updates (UPDATE ... WHERE id IN (...)), one for each group.
Query looks like this :
$a_data = array(
'A' => foo,
'B' => 99,
'C' => 0,
'D' => (0 OR 1 ?)
);
$where['id IN (?)'] = $a_id;
$update = $this->_db->update($this->_name, $a_data, $where);
Witch method can be the best way to do this ? Thanks