You are here

function _purl_migrate in Persistent URL 6

Migrate any modifiers from context_prefix tables to PURL.

1 call to _purl_migrate()
purl_install in ./purl.install
Implementation of hook_install().

File

./purl.install, line 65

Code

function _purl_migrate() {
  drupal_get_schema(NULL, TRUE);
  if (db_table_exists('purl') && db_table_exists('context_prefix')) {
    $result = db_query("SELECT * FROM {context_prefix}");
    while ($row = db_fetch_object($result)) {
      $exists = db_result(db_query("SELECT id FROM {purl} WHERE provider = '%s' AND id = '%d'", $row->provider, $row->id));
      if (!$exists) {
        $modifier = array(
          'value' => $row->prefix,
          'provider' => $row->provider,
          'id' => $row->id,
        );
        drupal_write_record('purl', $modifier);
      }
    }
    $ret = array();
    db_drop_table($ret, 'context_prefix');
  }
}