5 package CXGN
::Insitu
::DB
;
12 die "CXGN::Insitu::DB: need a database handle";
14 unless( ref($dbh) && $dbh->can('selectall_arrayref') ) {
15 die "Need a database handle as argument!\n";
17 my $self = bless {}, $class;
24 =head2 get_dbh, set_dbh
26 Usage: Accessors for the dbh property
27 Desc: the database handle is set in the
28 constructor and it should never be
29 necessary to call the setter. Always use
30 the getter to obtain a database handle,
31 do not try to cache it in some cheesy variable.
32 Ret: setter: database handle (fresh!)
33 Args: getter: a valid database handle, preferably
34 in the form of a CXGN::DB::Connection object.
35 Side Effects: this database handle is used in all database
36 transactions of this object.
54 Synopsis: my ($exp_count, $image_count, $tag_count)
57 Returns: a list of three values, representing the
58 number of experiments, images and counts
59 associated with the insitu database.
68 my $e_count_q = "SELECT count(*) FROM insitu.experiment";
69 my $eh = $self->get_dbh()->prepare($e_count_q);
71 my ($e_count) = $eh->fetchrow_array();
73 my $i_count_q = "SELECT count(*) FROM metadata.md_image join insitu.experiment_image using (image_id)";
74 my $ih = $self->get_dbh()->prepare($i_count_q);
76 my ($i_count) = $ih->fetchrow_array();
78 my $t_count_q = "SELECT count(*) FROM metadata.md_tag join insitu.experiment_tag using (tag_id)";
79 my $th = $self->get_dbh()->prepare($t_count_q);
81 my ($t_count) = $th->fetchrow_array();
83 return ($e_count, $i_count, $t_count);