зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
77f073b279
Коммит
adba24c93e
|
@ -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);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче