$remote_id) { // Get the list of cvterm_ids from existing records in the table. $sql = " SELECT $local_id FROM { " . $tablename . "} GROUP BY $local_id "; $results = chado_query($sql); while ($cvterm_id = $results->fetchField()) { // Get the CV term details and add it to the tripal_vocabulary table if // it doesn't already exist. $cvterm = chado_generate_var('cvterm', array('cvterm_id' => $cvterm_id)); // TODO insert records into the tripal_cvterm_mapping table. db_insert('tripal_cvterm_mapping') ->fields( array( 'cvterm_id' => $cvterm->cvterm_id, 'chado_table' => $tablename, 'chado_field' => $remote_id ) ) ->execute(); } } } } catch (Exception $e) { print "\n"; // make sure we start errors on new line $transaction->rollback(); watchdog_exception('tripal_chado', $e); print "FAILED: Rolling back database changes...\n"; } print "\nDone.\n"; }