[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Mon Jul 25 17:50:03 UTC 2005
mwilkinson
Mon Jul 25 13:50:02 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi
In directory pub.open-bio.org:/tmp/cvs-serv20439/MOBY/Adaptor/moby/queryapi
Modified Files:
mysql.pm
Log Message:
changing the adaptor API to be more perlish. No longer passing a list of hashes, just a hash
moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.28,1.29
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 20:00:10 1.28
+++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 17:50:02 1.29
@@ -75,25 +75,24 @@
my $driver = $self->driver; # inherited from the adaptorI (queryapi)
my $username = $self->username;
my $password = $self->password;
- my $port = $self->port;
- my $url = $self->url;
- my $dbname = $self->dbname;
-
- my ($dsn) = "$driver:$dbname:$url:$port";
-# print STDERR "\n\nconnectiung to $driver:$dbname:$url:$port\n\n";
- my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database";
+ my $port = $self->port;
+ my $url = $self->url;
+ my $dbname = $self->dbname;
+
+ my ($dsn) = "$driver:$dbname:$url:$port";
+ my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database";
- ##############################################################
- unless ($dbh) {
- print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n";
- return undef;
- }
-
+ ##############################################################
+ unless ($dbh) {
+ print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n";
+ return undef;
+ }
+
$self->dbh($dbh);
- #############################################################
+ #############################################################
- return undef unless $self->dbh;
+ return undef unless $self->dbh;
return $self;
}
@@ -162,29 +161,23 @@
}
}
}
-
-# general query subroutine
-# parameters:
-# statement - a string SQL statement
-# bind_values - an array of values to be bound to the parameters
-# returns:
-# resultset - reference to an array containing ARRAY references
-sub general_query{
- my ($self, @args) = @_;
- my $dbh = $self->dbh;
- my $statement = get_value('statement', @args);
- my $sth = $dbh->prepare($statement);
- if (@args > 1)
- {
- my $bindvalues = get_value('bind_values', @args);
- $sth->execute(@$bindvalues);
- }
- else {
- $sth->execute;
- }
- my $result = $sth->fetchall_arrayref();
- return $result;
-}
+#
+#sub general_query{
+# my ($self, @args) = @_;
+# my $dbh = $self->dbh;
+# my $statement = get_value('statement', @args);
+# my $sth = $dbh->prepare($statement);
+# if (@args > 1)
+# {
+# my $bindvalues = get_value('bind_values', @args);
+# $sth->execute(@$bindvalues);
+# }
+# else {
+# $sth->execute;
+# }
+# my $result = $sth->fetchall_arrayref();
+# return $result;
+#}
sub query_collection_input{
my ($self, @args) = @_;
@@ -207,15 +200,12 @@
}
sub insert_collection_input {
- my ($self, @args) = @_;
+ my ($self, %args) = @_;
my $dbh = $self->dbh;
-# if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){
- # this should be dropped down into the mysql.pm module?? probably...
$self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)",
- undef, (get_value('service_instance_id', @args), get_value('article_name', @args)));
+ undef, $args{'service_instance_id'},$args{'article_name'});
my $id=$self->dbh->{mysql_insertid};
return $id;
-# }
}
sub delete_collection_input{
More information about the MOBY-guts
mailing list