package ForumRegistrarDB;
use strict;
use warnings;
use Class::DBI::mysql;

sub testReg {
  return "RegistrarDB is loaded";
}

#
# Database interface for the RegistrarDB example using Class::DBI
# See the perldocs for Class::DBI for the many, many methods which this sets up.
# The basic ideas are
#   (a) each SQL table is a class : Person, Registration, Course, Status
#   (b) each row of those tables is an instance : $person, $course, $status, ...
#   (c) each column is a method on those objects : $person->name, $reg->course->name, ..
#
# Sample usage :
#
#  use RegistrarDB;
#
#  my $person  = Person->create( {name => "Jim", phone=>"111-2222"} );
#  my ($student) = Status->search( name => 'student' );
#  my @registrations = Registration->search( name => "Sally", status => $student );
#  print " Sally is registered to take courses : \n";
#  foreach my $reg (@registrations){
#    print "  " . $reg->course->name . "\n";
#  }
#
#
# Run test.pl to see an example of this in action.
#

my $DB_USER = 'glein';
my $DB_PASS = 'glein_pa55';
my $DB_DATA = 'glein_db';
my $dsn     = "DBI:mysql:database=$DB_DATA";

# Define the database connection
use base 'Class::DBI::mysql';
__PACKAGE__->set_db('Main', $dsn, $DB_USER, $DB_PASS);
__PACKAGE__->autoupdate(1);

package Person;
use base 'ForumRegistrarDB';
__PACKAGE__->set_up_table('Person');



package RegistrarDB;
# All perl packages must return true.
1;



