#!/usr/bin/perl
package Author;

#####################################################################
# Author : Shuai Weng
# Date   : July 2001
#
# See documentation for usage details:
#
# http:///usr/local/dicty/www_dictybase/db/lib/staff/dictyBase/programmer/Author.html
#
#####################################################################

use strict;
use DBI;
use Carp;
use vars qw (@ISA %allowedConstructors);
use dictyBase_Table;
@ISA = qw (dictyBase_Table); # base class

# Class Globals

# put column names in the hash below, that are able to uniquely
# specify a row in the table

%allowedConstructors = (author_no=>undef,
                        author_name=>undef);


####################################################################
sub GetAuthorListBYname {
####################################################################
    my ($self, %args) = @_;
    my $dbh = $args{'dbh'} || die "A database handle must be passed to the 'GetAuthorListBYname' method.";
    my $schema = $self->schema;
    my $sth = $dbh->prepare("
        SELECT author_name
        FROM   $schema.author
        WHERE  upper(author_name) like ?
    ");
    $sth->execute(uc($args{'author'}));
    my $arrayRef = $sth->fetchall_arrayref();
    $sth->finish();
    return $arrayRef;
}

####################################################################
sub DESTROY{
####################################################################
# nothing needs to be done

}


####################################################################
1; #################################################################
####################################################################

=pod

=head1 Name

Author.pm

=head1 Description

This perl object (Author.pm) acts as container for Author info in oracle database. Once an object has been instantiated, several methods are available to retrieve the attributes of the object.


=head1 Instantiating a New Author Object

To instantiate a new Author object, you may use one of the following syntaxes:

my $Obj = Author->new(dbh=>$dbh,
                      author_no=>$authorNo);


OR


my $Obj = Author->new(dbh=>$dbh,
                      author_name=>$author);


where $dbh is a valid database handle to either dictyBase or SDEV. All passed in values must be valid values for the columns that were provided, otherwise the script will die, with an appropriate error message.


=head1 Accessor Methods


All accessor methods take the form of :

my $column_value = $obj->column_name, eg:

my $author = $Obj->author_name;

my $createdBy = $Obj->created_by;


etc. You can use an accessor for any valid column in the Author table.

See valid columns in author table:

http:///usr/local/dicty/www_dictybase/db/lib/cgi-bin/dictyBase/tableSpecifications?table=AUTHOR

=head1 getRow method

Usage:

my $row = $obj->getRow;

This method returns a tab-delimited row from author table.

=head1 Insert, update and delete Methods

You can also use 'Insert' class method and 'update' and 'delete'
instance methods for inserting new row into database, updating and
deleting info for a specified row.

See dictyBase_Table documentation for usage details :

Update : http:///usr/local/dicty/www_dictybase/db/lib/staff/dictyBase/programmer/dictyBase_Table.html#Update_Method

Insert : http:///usr/local/dicty/www_dictybase/db/lib/staff/dictyBase/programmer/dictyBase_Table.html#Insert_Method

Delete : http:///usr/local/dicty/www_dictybase/db/lib/staff/dictyBase/programmer/dictyBase_Table.html#Delete_Method

=head1 GetAuthorListBYname method

Usage :

my $authorArrayRef = Author->GetAuthorListBYname(dbh=>$dbh,
                                                 author=>'cher%');

foreach my $rowRef (@$authorArrayRef) {

    my ($author) = @$rowRef;

    print $author, "\n";

}


=head1 Author

Shuai Weng

shuai@genome.stanford.edu

=cut










