| 1 | package RWDE::DB::Deletable; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use vars qw($VERSION); | ||
| 7 | $VERSION = sprintf "%d", q$Revision: 508 $ =~ /(\d+)/; | ||
| 8 | |||
| 9 | =pod | ||
| 10 | |||
| 11 | =head2 delete_record() | ||
| 12 | |||
| 13 | Delete the present record from the DB | ||
| 14 | |||
| 15 | Requires the present record to be: | ||
| 16 | - populated | ||
| 17 | - have an index | ||
| 18 | |||
| 19 | =cut | ||
| 20 | |||
| 21 | sub delete_record { | ||
| 22 | my ($self, $params) = @_; | ||
| 23 | |||
| 24 | my $dbh = $self->get_dbh(); | ||
| 25 | |||
| 26 | my $id_name = $self->{_id}; | ||
| 27 | my $count = $dbh->do("DELETE FROM " . $self->{_table} . " WHERE " . $self->{_id} . "=" . $self->$id_name); | ||
| 28 | |||
| 29 | return $count; | ||
| 30 | } | ||
| 31 | |||
| 32 | 1; |