EnsEMBL::Web::Data Genomic
Included librariesPackage variablesGeneral documentationMethods
Toolbar
WebCvsRaw content
Package variables
Privates (from "my" definitions)
%dbh;
$current_dbh;
Included modules
DBI
Inherit
Unavailable
Synopsis
No synopsis!
Description
No description!
Methods
connect
No description
Code
db_Main
No description
Code
Methods description
None available.
Methods code
connectdescriptionprevnextTop
sub connect {
    my $self    = shift;
    my $species = shift || __PACKAGE__->species_defs->ENSEMBL_PRIMARY_SPECIES;
    my $db      = shift || 'DATABASE_CORE';
    my $db_info =  __PACKAGE__->species_defs->get_config($species, 'databases');

    my $dsn = join(':',
      'dbi',
      'mysql',
      $db_info->{$db}{'NAME'},
      $db_info->{$db}{'HOST'},
      $db_info->{$db}{'PORT'},
    );

    if ($dbh{$dsn}) {
        $self->{__current_dbh} = $dbh{$dsn};
    } else {
        $self->{__current_dbh} = $dbh{$dsn} = DBI->connect_cached(
            $dsn,
            __PACKAGE__->species_defs->DATABASE_WRITE_USER,
            __PACKAGE__->species_defs->DATABASE_WRITE_PASS,
            {
              RaiseError => 1,
              PrintError => 1,
              AutoCommit => 1,
            }
        );
        if (not $self->{__current_dbh}) {
            warn "Could not connect to '$dsn' $DBI::errstr";
            return 0;
        }
    }
    
    $current_dbh = $self->{__current_dbh};
    return 1;
}
db_MaindescriptionprevnextTop
sub db_Main {
    my $self = shift;
    
    if (ref $self) {
      return $self->{__current_dbh};
    } else {
      return $current_dbh;
    }
}

1;
}
General documentation
No general documentation available.