These documents are For the HEAD of the CVS repository on July 19, 2007
Api docs for previous releases
Modware
DBH
Modware::DBH - Global database connection object. Use for commits, rollbacks, custom SQL.
|
No package variables defined. |
Chado::AutoDBI |
Data::Dumper |
# USE CASE: PERFORM A DATABASE TRANSACTION WITH ROLLBACK ON ERROR my $dbh = new Modware::DBH; eval { my $feature = new Modware::Feature( -primary_id => 'DDB0191090' ); $feature->description('abc');
# some more error prone code
}; if ($@){ warn $@;
# ROLLBACK WILL BE ISSUED ON ALL DATABASE CHANGES INVOLVING Modware OR # A DATABASE HANDLE CREATED WITH my $dbh = new Modware::DBH $dbh->rollback(); }
|
This is a singleton class: every call to 'new Modware::DBH' will return the same database handle: that used by Chado::AutoDBI
Use this class to issue direct sql against the database and also for commits and rollbacks.
You normally will not have to commit though since destructor for this class issues a commit on unloading.
|
Methods description
Title : _insert_primary_id
Usage : $feature->_insert_primary_id;
Function : inserts and links primary_id to feature
Returns : Chado::Dbxref object
Args : none
Methods code
Chado::Feature::next_unique_name | description | top | prev | next |
sub Chado::Feature::next_unique_name
{ my ($class, @args) = @_;
my $dbh = new Modware::DBH;
$sth = $dbh->prepare("select nextval('feature_uniquename_seq')");
$sth->execute();
my $return = $sth->fetchrow();
$sth->finish();
return $return;
}
sub get_public_id
{ my ( $self, $prefix ) = @_;
# prefix should be passed in, but a default is the $ENV{'IDENTIFIER_PREFIX'}
# from config.xml
$prefix ||= $ENV{'IDENTIFIER_PREFIX'};
my $number = Chado::Feature->next_unique_name();
$number = sprintf("%08d", $number);
my $new_id = $ENV{'IDENTIFIER_PREFIX'};
$new_id.= $number;
# created the dbxref
my $dbxref = Chado::Dbxref->find_or_create(
db_id => Modware::Constant->Application_db_id(),
accession => $new_id
);
return $dbxref;
}
sub new
{ Chado::DBI->db_Main();
}
General documentation
Copyright © 2006, Northwestern University
All rights reserved.
|
|