function date_update_2 in Date 5
Same name and namespace in other branches
- 5.2 date/date.install \date_update_2()
File
- ./
date.install, line 70
Code
function date_update_2() {
$ret = array();
if (!db_table_exists('node_field_date_data')) {
return $ret;
}
// Multi-part update
if (!isset($_SESSION['date_update_2'])) {
$_SESSION['date_update_2'] = 0;
$_SESSION['date_update_2_max'] = db_result(db_query("SELECT COUNT(*) FROM {node_field_date_data}"));
}
$limit = 20;
$result = db_query_range("SELECT nr.nid, nfdd.vid, nfdd.field_name, nfdd.delta FROM {node_field_date_data} nfdd LEFT JOIN {node_revisions} nr ON nr.vid = nfdd.vid", $_SESSION['date_update_2'], $limit);
if (db_num_rows($result) == 0) {
unset($_SESSION['date_update_2']);
unset($_SESSION['date_update_2_max']);
return array();
}
while ($data = db_fetch_object($result)) {
$_SESSION['date_update_2']++;
db_query("UPDATE {node_field_date_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['date_update_2'] / $_SESSION['date_update_2_max'],
);
}