Adding a new way of executing database statements: attempt(). Works like execute() but doesn't raise an exception on failure. Check for failure by using the ResultsFrame's 'lastError' method.

This commit is contained in:
ian%hixie.ch 2002-09-12 11:44:07 +00:00
Родитель 77f073b279
Коммит adba24c93e
1 изменённых файлов: 8 добавлений и 0 удалений

Просмотреть файл

@ -113,6 +113,12 @@ sub execute {
$self->createResultsFrame($statement, 1, @values); # note: @values might be empty
}
sub attempt {
my $self = shift;
my($statement, @values) = @_;
$self->createResultsFrame($statement, 0, @values); # note: @values might be empty
}
sub createResultsFrame {
my $self = shift;
my($statement, $execute, @values) = @_;
@ -129,6 +135,8 @@ sub createResultsFrame {
my $handle = $self->handle->prepare($statement);
if ($handle and ((not defined($execute)) or $handle->execute(@values))) {
return PLIF::Database::ResultsFrame::DBI->create($handle, $self, $execute);
} elsif (not $execute) {
return PLIF::Database::ResultsFrame::DBI->create($handle, $self, $execute);
} else {
$self->error(1, $handle->errstr);
}