You are here

function _radioactivity_arbitrary_target_id_mapper in Radioactivity 5

1 string reference to '_radioactivity_arbitrary_target_id_mapper'
radioactivity_arbitrary_target_radioactivity_info in plugins/radioactivity_arbitrary_target.module

File

plugins/radioactivity_arbitrary_target.module, line 26

Code

function _radioactivity_arbitrary_target_id_mapper($oid, $oclass) {

  // check if we already have $oid mapped
  $result = db_query("SELECT rad_id FROM {radioactivity_arbitrary_target} WHERE arb_id='%s'", $oid);
  $rad_id = db_result($result);
  if ($rad_id) {
    return $rad_id;
  }

  // no mapping yet, so create one
  $rad_id = db_next_id('{radioactivity_arbitrary_target}_rad_id');
  db_query("INSERT INTO {radioactivity_arbitrary_target} (rad_id, arb_id) VALUES (%d, '%s')", $rad_id, $oid);
  return $rad_id;
}