/Vector/Thread.pm
use Vector::DB;
use strict;
{
my ($class, $post_id) = @_;
my $dbh = Vector::DB::connect;
$dbh->do('INSERT INTO threads (post_id, updated) VALUES (?, NOW())', undef, $post_id)
or die "Could not create thread $post_id";
return fetch Vector::Thread($post_id);
}
{
my ($class, $post_id) = @_;
my $dbh = Vector::DB::connect;
my $self = $dbh->selectrow_hashref('SELECT post_id, updated FROM threads WHERE post_id = ?', undef, $post_id)
or die "Could not fetch thread $post_id";
return bless $self, $class;
}
{
my ($self) = @_;
my $dbh = Vector::DB::connect;
$dbh->do('UPDATE threads SET updated =? WHERE post_id = ?', undef, $self->{ }, $self->{ })
or die "Could not save thread $self->{post_id}";
}
{
my ($self) = @_;
my $dbh = Vector::DB::connect;
$dbh->do('UPDATE threads SET updated=NOW() WHERE post_id = ?', undef, $self->{ });
($self->{ }) = $dbh->selectrow_array('SELECT updated FROM threads WHERE post_id = ?', undef, $self->{ });
}
1;