#!/usr/bin/perl
package Dbuser;

#####################################################################
# Author : Shuai Weng
# Date   : July 2001
# 
# See documentation for the usage details. 
#    
# http:///usr/local/dicty/www_dictybase/db/lib/html/dictyBase/programmer/Dbuser.html
#
#####################################################################
#   Usage: 
#     
#   use Dbuser;
#
#   ### You may use one of the following syntax 
#   ### instantiate a new Dbuser object.
#
#   my $dbuserObj = Dbuser->new(dbh=>$dbh,
#                               userid=>$userid);
#       
#
#   ### You can use an accessor for any valid column 
#   ### in the Dbuser table. For example: 
#   my $fname = $dbuserObj->first_name;
#   my $lname = $dbuserObj->last_name;
#
#   See documentation for detail.
#   
#   http:///usr/local/dicty/www_dictybase/db/lib/html/dictyBase/programmer/Dbuser.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 = (userid=>undef);

########################################################################
sub GetDbuserDetail {
########################################################################
    my ($self, %args) = @_;
    my $dbh = $args{'dbh'};
    my $table = $self->schema.".dbuser";
    my $sth = $dbh->prepare("
        SELECT userid, first_name, last_name, status, email, 
               date_created 
	FROM   $table
        ORDER BY upper(userid)
    ");
    $sth->execute;
    my $arrayRef = $sth->fetchall_arrayref();
    return $arrayRef;
}

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

}


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


=pod

=head1 Name

Dbuser.pm

=head1 Description

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


=head1 Instantiating a New Dbuser Object

To instantiate a new Dbuser object, you may use following syntax: 

my $dbuserObj = Dbuser->new(dbh=>$dbh, $colNm=>$value); 

where $colNm is userid and $dbh is a valid database handle to either dictyBase or SDEV. $value must be a valid value for the column that was provided, otherwise the script will die, with an appropriate error message.
 

Syntax example :

my $dbuserObj = Dbuser->new(dbh=>$dbh, userid=>$userid); 


=head1 Accessor Methods


All accessor methods take the form of : 


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


my $first_name = $dbuserObj->first_name; 


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

See valid columns in abstact table:

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


=head1 getRow method

Usage:

my $row = $dbuserObj->getRow;

This method returns a tab-delimited row from dbuser 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


In addition, you can use following Class method to dump the table 
and return an array reference to the data.

=head1 GetDbuserDetail

Usage:

my $arrayRef = Dbuser->GetDbuserDetail(dbh=>$dbh);

foreach my $rowRef (@$arrayRef) {
     my ($userid, $fname, $lname, $status, $email, $dateCreated) 
	 = @$rowRef;

     ....

}


=head1 Author

Shuai Weng

shuai@genome.stanford.edu

=cut











