function text_update_3 in Content Construction Kit (CCK) 5
Populate nid column in existing long-text fields.
File
- ./
text.install, line 59
Code
function text_update_3() {
// Multi-part update
if (!isset($_SESSION['text_update_3'])) {
$_SESSION['text_update_3'] = 0;
$_SESSION['text_update_3_max'] = db_result(db_query("SELECT COUNT(*) FROM {node_field_shorttext_data}"));
}
$limit = 20;
$result = db_query_range("SELECT nr.nid, nfld.vid, nfld.field_name, nfld.delta FROM {node_field_longtext_data} nfld LEFT JOIN {node_revisions} nr ON nr.vid = nfld.vid", $_SESSION['text_update_3'], $limit);
if (db_num_rows($result) == 0) {
unset($_SESSION['text_update_3']);
unset($_SESSION['text_update_3_max']);
return array();
}
while ($data = db_fetch_object($result)) {
$_SESSION['text_update_3']++;
db_query("UPDATE {node_field_longtext_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['text_update_3'] / $_SESSION['text_update_3_max'],
);
}