You are here

function nodewords_update_6151 in Nodewords: D6 Meta Tags 6

Implements hook_update_N().

File

./nodewords.install, line 999
Installation file for nodewords.module.

Code

function nodewords_update_6151(&$sandbox) {
  $ret = array();
  if (!isset($sandbox['progress'])) {
    $sandbox['progress'] = 0;
    $sandbox['current_pid'] = 0;
    $sandbox['max'] = db_result(db_query("SELECT COUNT(*) FROM {nodewords_custom} WHERE name = ''"));
  }
  if ($sandbox['max']) {
    $pages = db_query_range("SELECT * FROM {nodewords_custom} WHERE name = '' AND pid > %d ORDER BY pid ASC", $sandbox['current_pid'], 0, 10);
    while ($page = db_fetch_object($pages)) {
      $ret[] = update_sql("UPDATE {nodewords_custom} SET name = '" . db_escape_string("Custom page #{$sandbox['progress']}") . "' WHERE pid = " . $page->pid);
      $sandbox['current_pid'] = $page->pid;
      $sandbox['progress']++;
    }
  }
  $ret['#finished'] = empty($sandbox['max']) ? 1 : $sandbox['progress'] / $sandbox['max'];
  return $ret;
}