The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<HTML>
<HEAD>
<TITLE>Bio::Genex::ExternalDatabase - Methods for processing data from the GeneX DB
 table: ExternalDatabase</TITLE>
<LINK REV="made" HREF="mailto:jasons@amadeus.avesthagen.com">
</HEAD>

<BODY>

<A NAME="__index__"></A>
<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#name">NAME</A></LI>
	<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
	<LI><A HREF="#description">DESCRIPTION</A></LI>
	<LI><A HREF="#attributes">ATTRIBUTES</A></LI>
	<LI><A HREF="#class variables">CLASS VARIABLES</A></LI>
	<LI><A HREF="#delayed fetch">DELAYED FETCH</A></LI>
	<LI><A HREF="#class methods">CLASS METHODS</A></LI>
	<LI><A HREF="#instance methods">INSTANCE METHODS</A></LI>
	<LI><A HREF="#attribute methods">ATTRIBUTE METHODS</A></LI>
	<LI><A HREF="#implementation details">IMPLEMENTATION DETAILS</A></LI>
	<LI><A HREF="#bugs">BUGS</A></LI>
	<LI><A HREF="#last updated">LAST UPDATED</A></LI>
	<LI><A HREF="#author">AUTHOR</A></LI>
	<LI><A HREF="#see also">SEE ALSO</A></LI>
</UL>
<!-- INDEX END -->

<HR>
<P>
<H1><A NAME="name">NAME</A></H1>
<P>Bio::Genex::ExternalDatabase - Methods for processing data from the GeneX DB
 table: ExternalDatabase</P>
<P>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<PRE>
  use Bio::Genex::ExternalDatabase;</PRE>
<PRE>
  # instantiating an instance
  my $ExternalDatabase = Bio::Genex::ExternalDatabase-&gt;new(id=&gt;47);</PRE>
<PRE>
  # retrieve data from the DB for all columns
  $ExternalDatabase-&gt;fetch();</PRE>
<PRE>
  # creating an instance, without pre-fetching all columns
  my $ExternalDatabase = new Bio::Genex::ExternalDatabase(id=&gt;47);</PRE>
<PRE>
  # creating an instance with pre-fetched data
  my $ExternalDatabase = new Bio::Genex::ExternalDatabase(id=&gt;47, 'fetch_all'=&gt;1);</PRE>
<PRE>
  # retrieving multiple instances via primary keys
  my @objects = Bio::Genex::ExternalDatabase-&gt;get_objects(23,57,98)</PRE>
<PRE>
  # retrieving all instances from a table
  my @objects = Bio::Genex::ExternalDatabase-&gt;get_objects('ALL');</PRE>
<PRE>
  # retrieving the primary key for an object, generically
  my $primary_key = $ExternalDatabase-&gt;id();</PRE>
<PRE>
  # or specifically
  my $name_val = $ExternalDatabase-&gt;name();</PRE>
<PRE>
  # retreving other DB column attributes
  my $main_url_val = $ExternalDatabase-&gt;main_url();
  $ExternalDatabase-&gt;main_url($value);</PRE>
<PRE>
  my $parameterized_url_val = $ExternalDatabase-&gt;parameterized_url();
  $ExternalDatabase-&gt;parameterized_url($value);</PRE>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P>Each Genex class has a one to one correspondence with a GeneX DB table
of the same name (<EM>i.e.</EM> the corresponding table for Bio::Genex::ExternalDatabase is
ExternalDatabase).</P>
<P>Most applications will first create an instance of Bio::Genex::ExternalDatabase
and then fetch the data for the object from the DB by invoking
<A HREF="#item_fetch"><CODE>fetch()</CODE></A>. However, in cases where you may only be accessing a single
value from an object the built-in <A HREF="#delayed_fetch">delayed fetch</A>
mechanism can be used. All objects are created without pre-fetching
any data from the DB. Whenever an attribute of the object is accessed
via a getter method, the data for that attribute will be fetched from
the DB if it has not already been. Delayed fetching happens
transparently without the user needing to enable or disable any
features.</P>
<P>Since data is not be fetched from the DB <EM>until</EM> it is accessed by
the calling application, it could presumably save a lot of access time
for large complicated objects when only a few attribute values are
needed.</P>
<P>
<HR>
<H1><A NAME="attributes">ATTRIBUTES</A></H1>
<P>There are three different types of attributes which instances of
Bio::Genex::ExternalDatabase can access: <EM>raw</EM> foreign key attributes,
Obect-Oriented foreign key attributes, and simple column attributes.</P>
<DL>
<DT><STRONG><A NAME="item_Raw_Foreign_Keys_Attributes">Raw Foreign Keys Attributes</A></STRONG><BR>
<DD>
<DT><STRONG><A NAME="item_Object_Oriented_Foreign_Key_Attributes">Object Oriented Foreign Key Attributes</A></STRONG><BR>
<DD>
This mode presents foreign key attributes in a special way, with all
non-foreign key attributes presented normally. Foreign keys are first
retrieved from the DB, and then objects of the appropriate classes are
created and stored in slots. This mode is useful for applications that
want to process information from the DB because it automates looking
up information.
<P>Specifying the '<CODE>recursive_fetch</CODE>' parameter when calling <A HREF="#item_new"><CODE>new()</CODE></A>,
modifies the behavior of this mode. The value given specifies the
number of levels deep that fetch will be invoked on sub-objects
created.</P>
<P></P>
<DT><STRONG><A NAME="item_Simple_Column_Attributes">Simple Column Attributes</A></STRONG><BR>
<DD>
</DL>
<P>
<HR>
<H1><A NAME="class variables">CLASS VARIABLES</A></H1>
<P>Class Bio::Genex::ExternalDatabase defines the following utility variables for assisting
programmers to access the ExternalDatabase table.</P>
<DL>
<DT><STRONG><A NAME="item_%24Bio%3A%3AGenex%3A%3AExternalDatabase%3A%3ALIMIT">$Bio::Genex::ExternalDatabase::LIMIT</A></STRONG><BR>
<DD>
If defined, $LIMIT will set a limit on any select statements that can
return multiple instances of this class (for example <A HREF="#item_get_objects"><CODE>get_objects()</CODE></A>
or any call to a <CODE>ONE_TO_MANY</CODE> or <CODE>LOOKUP_TABLE</CODE> foreign key
accessor method).
<P></P>
<DT><STRONG><A NAME="item_%24Bio%3A%3AGenex%3A%3AExternalDatabase%3A%3AUSE_C">$Bio::Genex::ExternalDatabase::USE_CACHE</A></STRONG><BR>
<DD>
This variable controls whether the class will cache any objects
created in calls to <A HREF="#item_new"><CODE>new()</CODE></A>. Objects are cached by primary key. The
caching is very simple, and no effort is made to track whether
different invocations of <A HREF="#item_new"><CODE>new()</CODE></A> are being made for an object with
the same primary key value, but with different options set. If you
desire to reinstantiate an object with a different set of parameters,
you would need to undefine <CODE>$USE_CACHE</CODE> first.
<P></P></DL>
<P><STRONG>WARNING</STRONG>: variables other than those listed here are for internal use
only and are subject to change without notice. Use them at your own
risk.</P>
<P>
<HR>
<H1><A NAME="delayed fetch">DELAYED FETCH</A></H1>
<P>It is possible to retrieve only the subset of attributes one chooses
by simply creating an object instance and then calling the appropriate
getter function. The object will automatically fetch the value from
the DB when requested. This can potentially save time for large
complicated objects. This triggers a separate DB query for each
attribute that is accessed, whereas calling <A HREF="#item_fetch"><CODE>fetch()</CODE></A> will retrieve
all fields of the object with a single query.</P>
<P>For example:</P>
<PRE>
  my $ExternalDatabase = Bio::Genex::ExternalDatabase-&gt;new(id=&gt;47);
  my $val = $ExternalDatabase-&gt;name();</PRE>
<P>The attribute's value is then cached in the object so any further calls
to that attribute's getter method do not trigger a DB query.</P>
<P><STRONG>NOTE</STRONG>: Methods may still return <CODE>undef</CODE> if their value in
the DB is <CODE>NULL</CODE>.</P>
<P>
<HR>
<H1><A NAME="class methods">CLASS METHODS</A></H1>
<P>The following methods can all be called without first having an
instance of the class via the Bio::Genex::ExternalDatabase-&gt;<CODE>methodname()</CODE> syntax.</P>
<DL>
<DT><STRONG><A NAME="item_new"><CODE>new(%args)</CODE></A></STRONG><BR>
<DD>
<A HREF="#item_new"><CODE>new()</CODE></A> accepts the following arguments:
<DL>
<DT><STRONG><A NAME="item_id">id</A></STRONG><BR>
<DD>
Numeric or string value. The value of the primary key for looking up
the object in the DB.
<P></P></DL>
<DT><STRONG><A NAME="item_linking_table"><CODE>linking_table()</CODE></A></STRONG><BR>
<DD>
Used by generic functions to determine if a specified class is a
linking table class. For Bio::Genex::ExternalDatabase it returns 0, since it is
<EM>not</EM> a linking table class.
<P></P>
<DT><STRONG><A NAME="item_pkey_name"><CODE>pkey_name()</CODE></A></STRONG><BR>
<DD>
This method returns the name of the column which is used as the
primary key for this DB table. This method only exists for non-linking
table classes, and for Bio::Genex::ExternalDatabase it returns the value 'name';
<P></P>
<DT><STRONG><A NAME="item_table_name"><CODE>table_name()</CODE></A></STRONG><BR>
<DD>
Returns the name of the DB table represented by this class. For
Bio::Genex::ExternalDatabase it returns 'ExternalDatabase';
<P></P>
<DT><STRONG><A NAME="item_column2name"><CODE>column2name()</CODE></A></STRONG><BR>
<DD>
This method returns a hashref that translates DB column names into
human readable format.
<P></P>
<DT><STRONG><A NAME="item_name2column"><CODE>name2column()</CODE></A></STRONG><BR>
<DD>
This method returns a hashref that is a reverse lookup table to
translate the human readable version of a DB column name back into the
column_name. This is useful for preparing table output in CGI scripts:
<PRE>
    %column2name = %{$class-&gt;column2name()};
    if (exists $column2name{$_}) {
      push(@column_copy,$column2name{$_});
    }
</PRE>
<PRE>

    # now that we've translated the names, we sort them
    @column_copy = sort @column_copy;</PRE>
<PRE>

    # make a header element. 
    push(@rows,th(\@column_copy));</PRE>
<P></P>
<DT><STRONG><A NAME="item_fkeys"><CODE>fkeys()</CODE></A></STRONG><BR>
<DD>
This method returns a hashref that holds all the foreign key entries
for the ExternalDatabase table.
<P></P>
<DT><STRONG><A NAME="item_column_names"><CODE>column_names()</CODE></A></STRONG><BR>
<DD>
This method returns an array ref which holds the names of all the
columns in table ExternalDatabase.
<PRE>
    # first retrieve the data from the DB
    $object = $full_module_name-&gt;new(id=&gt;$id);
    $object-&gt;fetch();</PRE>
<PRE>
    # now extract the data from the object
    foreach (@{$class-&gt;column_names}) {
    # we use this to temporarily relax the strict pragma
    # to use symbolic references
      no strict 'refs';
      $tmp_values{$_} = $object-&gt;$_;</PRE>
<PRE>
    # back to our regularily scheduled strictness
    }</PRE>
<P></P>
<DT><STRONG><A NAME="item_insert_db"><CODE>insert_db($dbh)</CODE></A></STRONG><BR>
<DD>
This method inserts the data for the object into the database
specified by the DB handle $dbh. To use this method, create a blank
object with <A HREF="#item_new"><CODE>new()</CODE></A>, set the attributes that you want, and then call
<A HREF="#item_insert_db"><CODE>insert_db()</CODE></A>.
<PRE>
  my $dbh = Bio::Genex::current_connection(USER=&gt;$SU_USERNAME,
                                      PASSWORD=&gt;$SU_PASSWORD);
  my ExternalDatabase = Bio::Genex::ExternalDatabase-&gt;new();
  ExternalDatabase-&gt;main_url('some_value');
  ExternalDatabase-&gt;insert_db($dbh);</PRE>
<P><STRONG>NOTE:</STRONG> You must log into the DB with a user/password that has INSERT
priveleges in the DB, otherwise you will get a DBI error.</P>
<P><STRONG>WARNING:</STRONG> <A HREF="#item_fetch"><CODE>fetch()</CODE></A> will <EM>not</EM> be called, so if you are using this
method to insert a copy of an existing DB object, then it is up to you
to call <A HREF="#item_fetch"><CODE>fetch()</CODE></A>, otherwise, only the attributes that are currently
set in the object will be inserted.</P>
<P></P>
<DT><STRONG><A NAME="item_update_db"><CODE>update_db($dbh)</CODE></A></STRONG><BR>
<DD>
This method update the data for an object already in the database
specified by the DB handle $dbh. To use this method, fetch an
object from the DB, change the attributes that you want, and then call
<A HREF="#item_update_db"><CODE>update_db()</CODE></A>.
<PRE>
  my $dbh = Bio::Genex::current_connection(USER=&gt;$SU_USERNAME,
                                      PASSWORD=&gt;$SU_PASSWORD);
  my ExternalDatabase = Bio::Genex::ExternalDatabase-&gt;new(id=&gt;43);
  ExternalDatabase-&gt;main_url('some_value');
  ExternalDatabase-&gt;update_db($dbh);</PRE>
<P><STRONG>NOTE:</STRONG> You must log into the DB with a user/password that has INSERT
priveleges in the DB, otherwise you will get a DBI error.</P>
<P><STRONG>NOTE:</STRONG> Any modification of the primary key value will be discarded
('name' for module Bio::Genex::ExternalDatabase).</P>
<P></P>
<DT><STRONG><A NAME="item_get_objects"><CODE>get_objects(@id_list)</CODE></A></STRONG><BR>
<DD>
<DT><STRONG><CODE>get_objects('ALL')</CODE></STRONG><BR>
<DD>
<DT><STRONG>get_objects({column=&gt;'col_name',value=&gt;'val'})</STRONG><BR>
<DD>
This method is used to retrieve multiple instances of class Bio::Genex::ExternalDatabase
simultaneously. There are three different ways to invoke this method.
<P>By passing in an <CODE>@id_list</CODE>, <A HREF="#item_get_objects"><CODE>get_objects()</CODE></A> uses each element of the
list as a primary key for the ExternalDatabase table and returns a single
instance for each entry.</P>
<P><STRONG>WARNING</STRONG>: Passing incorrect id values to <A HREF="#item_get_objects"><CODE>get_objects()</CODE></A> will cause
a warning from <CODE>Bio::Genex::ExternalDatabase::initialize()</CODE>. Objects will be
created for other correct id values in the list.</P>
<P>By passing the 'ALL' parameter, <A HREF="#item_get_objects"><CODE>get_objects()</CODE></A> returns an instance
for every entry in the table.</P>
<P>By passing an anonymous hash reference that contains the 'column' and
'name' keys, the method will return all objects from the DB whose that
have the specified value in the specified column.</P>
<P></P></DL>
<P><STRONG>NOTE</STRONG>: All objects must have the 'id' parameter set before attempting
to use <A HREF="#item_fetch"><CODE>fetch()</CODE></A> or any of the objects getter functions.</P>
<P>
<HR>
<H1><A NAME="instance methods">INSTANCE METHODS</A></H1>
<P>The following methods can only be called by first having valid
instance of class Bio::Genex::ExternalDatabase.</P>
<DL>
<DT><STRONG><A NAME="item_fetch"><CODE>fetch()</CODE></A></STRONG><BR>
<DD>
This method triggers a DB query to retrieve <STRONG>ALL</STRONG> columns from the DB
associated with this object.
<P></P></DL>
<P><STRONG>WARNING</STRONG>: methods other than those listed here are for internal use
only and are subject to change without notice. Use them at your own
risk.</P>
<P>
<HR>
<H1><A NAME="attribute methods">ATTRIBUTE METHODS</A></H1>
<P>These are the setter and getter methods for attributes in class
Bio::Genex::ExternalDatabase.</P>
<P><STRONG>NOTE</STRONG>: To use the getter methods, you may either invoke the
<A HREF="#item_fetch"><CODE>fetch()</CODE></A> method to retrieve all the values for an object, or else
rely on <A HREF="#delayed_fetch">delayed fetching</A> to retrieve the attributes
as needed.</P>
<DL>
<DT><STRONG><CODE>id()</CODE></STRONG><BR>
<DD>
<A HREF="#item_id"><CODE>id()</CODE></A> is a special attribute method that is common to all the Genex
classes. This method returns the primary key of the given instance
(and for class Bio::Genex::ExternalDatabase it is synonomous with the
<A HREF="#item_name"><CODE>name()</CODE></A>method). The <A HREF="#item_id"><CODE>id()</CODE></A> method can be useful in writing
generic methods because it avoids having to know the name of the
primary key column.
<P></P>
<DT><STRONG><A NAME="item_name"><CODE>name()</CODE></A></STRONG><BR>
<DD>
This is the primary key attribute for Bio::Genex::ExternalDatabase. It has no setter method.
<P></P>
<DT><STRONG><A NAME="item_main_url">$value = main_url();</A></STRONG><BR>
<DD>
<DT><STRONG>main_url($value);</STRONG><BR>
<DD>
Methods for the main_url attribute.
<P></P>
<DT><STRONG><A NAME="item_parameterized_url">$value = parameterized_url();</A></STRONG><BR>
<DD>
<DT><STRONG>parameterized_url($value);</STRONG><BR>
<DD>
Methods for the parameterized_url attribute.
<P></P></DL>
<P><STRONG>WARNING</STRONG>: methods other than those listed here are for internal use
only and are subject to change without notice. Use them at your own
risk.</P>
<P>
<HR>
<H1><A NAME="implementation details">IMPLEMENTATION DETAILS</A></H1>
<P>These classes are automatically generated by the
create_genex_classes.pl script.  Each class is a subclass of the
Class::ObjectTemplate::DB class (which is in turn a subclass of
Class::ObjectTemplate written by Sriram Srinivasan, described in
<EM>Advanced Perl Programming</EM>, and modified by Jason
Stewart). ObjectTemplate implements automatic class creation in perl
(there exist other options such as <CODE>Class::Struct</CODE> and
<CODE>Class::MethodMaker</CODE> by Damian Conway) via an <CODE>attributes()</CODE> method
call at class creation time.</P>
<P>
<HR>
<H1><A NAME="bugs">BUGS</A></H1>
<P>Please send bug reports to <A HREF="mailto:genex@ncgr.org">genex@ncgr.org</A></P>
<P>
<HR>
<H1><A NAME="last updated">LAST UPDATED</A></H1>
<P>on Tue Jan 23 22:53:43 2001 by /home/jasons/work/GeneX-WWW-Installer/Genex/scripts/create_genex_class.pl --dir=/home/jasons/work/GeneX-WWW-Installer/Genex --target=ExternalDatabase</P>
<P>
<HR>
<H1><A NAME="author">AUTHOR</A></H1>
<P>Jason E. Stewart (<A HREF="mailto:jes@ncgr.org">jes@ncgr.org</A>)</P>
<P>
<HR>
<H1><A NAME="see also">SEE ALSO</A></H1>
<P>perl(1).</P>

</BODY>

</HTML>