You are here

function _tvi_update_move_6001 in Taxonomy Views Integrator 6

Moves all records from the previous table into the new one and remove the old table afterwords, if all records were transferred successfully.

1 call to _tvi_update_move_6001()
tvi_update_6001 in ./tvi.install
Implements tvi_hook_update_N().

File

./tvi.install, line 165
Installation file for TVI module.

Code

function _tvi_update_move_6001(&$ret, $table, $id_field, $type) {

  // Copy old table values into new table.
  $results = db_query("SELECT * FROM {$table}");
  while ($settings = db_fetch_array($results)) {
    $xid = $settings[$id_field];
    $view_id = $settings['viewid'];
    $display = $settings['display'];
    $status = $settings['status'];
    $result = update_sql('INSERT INTO {tvi_settings}' . ' (type, xid, view_id, display, status)' . " VALUES ('{$type}', {$xid}, {$view_id}, '{$display}', {$status})");
    $ret[] = $result;
    if (!$result['success']) {
      $failed = TRUE;
    }
  }
  if (!$failed) {
    db_drop_table($ret, $table);
  }
}