You are here

function number_update_2 in Content Construction Kit (CCK) 5

File

./number.install, line 28

Code

function number_update_2() {

  // Multi-part update
  if (!isset($_SESSION['number_update_2'])) {
    $_SESSION['number_update_2'] = 0;
    $_SESSION['number_update_2_max'] = db_result(db_query("SELECT COUNT(*) FROM {node_field_float_data}"));
  }
  $limit = 20;
  $result = db_query_range("SELECT nr.nid, nffd.vid, nffd.field_name, nffd.delta FROM {node_field_float_data} nffd LEFT JOIN {node_revisions} nr ON nr.vid = nffd.vid", $_SESSION['number_update_2'], $limit);
  if (db_num_rows($result) == 0) {
    unset($_SESSION['number_update_2']);
    unset($_SESSION['number_update_2_max']);
    return array();
  }
  while ($data = db_fetch_object($result)) {
    $_SESSION['number_update_2']++;
    db_query("UPDATE {node_field_float_data} SET nid = %d WHERE vid = %d AND field_name = '%s' AND delta = %d", $data->nid, $data->vid, $data->field_name, $data->delta);
  }
  return array(
    '#finished' => $_SESSION['number_update_2'] / $_SESSION['number_update_2_max'],
  );
}