function tripal_analysis_delete_analyses
2.x tripal_analysis.delete.inc | tripal_analysis_delete_analyses($analyses, $job = NULL) |
3.x tripal_analysis.delete.inc | tripal_analysis_delete_analyses($analyses, $job = NULL) |
Function to actually delete the features indicated
Parameters
$analysis_id: The list of analysis_id of the features to delete
$job: The tripal_job id
Related topics
1 string reference to 'tripal_analysis_delete_analyses'
- tripal_analysis_delete_form_submit in tripal_analysis/
includes/ tripal_analysis.delete.inc - Submit for the delete features form
File
- tripal_analysis/
includes/ tripal_analysis.delete.inc, line 82 - Administration Interface for deleting multiple analyses
Code
function tripal_analysis_delete_analyses($analyses, $job = NULL) {
global $user;
// Deleting of analyses will cause a cascade delete on the
// fassociated tables which may include the fatureloc table. The create_point
// function which is not prefix with the schema, and an error occurs.
// Therefore, we set the active database to chado to get around that
// problem.
// $previous_db = chado_set_active('chado');
// begin the transaction
$transaction = db_transaction();
print "\nNOTE: Deleting analyses is performed using a database transaction. \n" .
"If the load fails or is terminated prematurely then the entire set of \n" .
"deletions is rolled back and will not be found in the database\n\n";
try {
$values = array(
'analysis_id' => $analyses
);
$num_deletes = chado_select_record('analysis', array('count(*) as cnt'), $values);
print "Deleting " . $num_deletes[0]->cnt . " analyses\n";
chado_delete_record('analysis', $values);
print "Removing orphaned analysis pages\n";
chado_cleanup_orphaned_nodes('analysis');
}
catch (Exception $e) {
print "\n"; // make sure we start errors on new line
$transaction->rollback();
print "FAILED: Rolling back database changes...\n";
watchdog_exception('tripal_analysis', $e);
return 0;
}
// chado_set_active($previous_db);
print "\nDone\n";
}