public function update_batch($table, $set = NULL, $index = NULL, $batch_size = 100)
{
// Combine any cached components with the current statements
$this->_merge_cache();
if ($index === NULL) {
return $this->db_debug ? $this->display_error('db_must_use_index') : FALSE;
}
if ($set === NULL) {
if (empty($this->qb_set)) {
return $this->db_debug ? $this->display_error('db_must_use_set') : FALSE;
}
} else {
if (empty($set)) {
return $this->db_debug ? $this->display_error('update_batch() called with no data') : FALSE;
}
$this->set_update_batch($set, $index);
}
if (strlen($table) === 0) {
if (!isset($this->qb_from[0])) {
return $this->db_debug ? $this->display_error('db_must_set_table') : FALSE;
}
$table = $this->qb_from[0];
}
// Batch this baby
$affected_rows = 0;
for ($i = 0, $total = count($this->qb_set); $i < $total; $i += $batch_size) {
$this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, $batch_size), $this->protect_identifiers($index)));
$affected_rows += $this->affected_rows();
$this->qb_where = array();
}
$this->_reset_write();
return $affected_rows;
}