Included libraries | Package variables | General documentation | Methods |
WebCvs | Raw content |
get_db | No description | Code |
prepare_statement | No description | Code |
set_db_args | No description | Code |
sub_db | No description | Code |
get_db | description | prev | next | Top |
if ($db){ return $db; }else{ warn "Not returning a db;"; return; } } } 1; __END__}
prepare_statement | description | prev | next | Top |
my( $text ) = @_; my $sth = sub_db()->prepare($text); push(@active_statement_handles, $sth); return $sth;}
set_db_args | description | prev | next | Top |
## take in user name password port etc, and use them to connect to the db}
my %args_hash = @_; $user = $args_hash{user} ; $dbname = $args_hash{db_name}; $host = $args_hash{host}; $port = $args_hash{port};
sub_db | description | prev | next | Top |
unless ($db) { # go to default values unless given already}
unless ($user) { $user= get_user();}; unless ($dbname) { $dbname = 'submissions'} ; unless (defined $host && defined $port){ ($host, $port)=Hum::SubmissionConf::localisation(); } if (my $test = $ENV{'SUBMISSION_TEST_DB'}) { # Legal formats:
#
# submissions_test
# submissions_test:3306
# submissions_test@ecs2b
# submissions_test@ecs2b:3306
if ($test =~ /^([\w_\$]+)(?:\@([\w\-\.]+))?(?::(\d+))?$/) { $dbname = $1; $host = $2 if $2; $port = $3 if $3; } else { confess "Can't parse SUBMISSION_TEST_DB environment variable '$test'"; } } # warn "DBI:mysql:host=$host;port=$port;database=$dbname:", $user;
# Make the database connection
$db = DBI->connect("DBI:mysql:host=$host;port=$port;database=$dbname", $user, undef, {RaiseError => 1, PrintError => 0}) or die "Can't connect to submissions database as '$user' ", DBI::errstr(); } return $db; } my( @active_statement_handles );
ref_from_query( SQL ) | Top |
NAME - Submission | Top |
AUTHOR | Top |