==={ In Hoch/Database/Base.pm }========================
package Hoch::Database::Base;
{
use strict;
use Class::DBI;
__PACKAGE__->connection(<your connection data here>)
}
1;
==={ In Hoch/Database/Journal.pm }======================
package Hoch::Database::Journal;
{
use strict;
use base 'Hoch::Database::Base';
__PACKAGE__->table('journal');
__PACKAGE__->columns(Primary => 'entry_id');
__PACKAGE__->columns(Essential => qw(entry_text date));
__PACKAGE__->has_a('date' => 'Class::Date');
}
1;
==={ In some script }=============================
use strict;
use Class::Date 'now';
use Hoch::Database::Journal;
my $date = Class::Date->now();
my $journal = Hoch::Database::Journal->create
({
date => $date,
entry_text => 'I ate all of my beans, and you can guess what happene
+d next',
});
my $entry_date = $journal->date();
print $entry_date->strftime("%A, %B %d, %Y");
|