AtteanX-Store-DBI
view release on metacpan or search on metacpan
lib/AtteanX/Store/DBI.pm view on Meta::CPAN
} elsif ($type eq 'postgresql') {
$sql = 'INSERT INTO quad (subject, predicate, object, graph) SELECT ?, ?, ?, ? WHERE NOT EXISTS (SELECT 1 FROM quad WHERE subject = ? AND predicate = ? AND object = ? AND graph = ?)';
push(@bind, @ids);
}
my $sth = $self->dbh->prepare($sql);
$sth->execute(@bind);
return;
}
=item C<< remove_quad ( $statement ) >>
Removes the specified C<$statement> from the underlying model.
=cut
sub remove_quad {
my $self = shift;
my $st = shift;
my @ids = map { $self->_get_term_id($_) } $st->values;
unless (scalar(@ids) == 4) {
return;
}
unless (all { defined($_) } @ids) {
return;
}
my $sth = $self->dbh->prepare('DELETE FROM quad WHERE subject = ? AND predicate = ? AND object = ? AND graph = ?');
$sth->execute(@ids);
return;
}
=item C<< create_graph( $graph ) >>
This is a no-op function for the memory quad-store.
=cut
sub create_graph {
# no-op on a quad-store
}
=item C<< drop_graph( $graph ) >>
Removes all quads with the given C<< $graph >>.
=cut
sub drop_graph {
my $self = shift;
return $self->clear_graph(@_);
}
=item C<< clear_graph( $graph ) >>
Removes all quads with the given C<< $graph >>.
=cut
sub clear_graph {
my $self = shift;
my $graph = shift;
my $gid = $self->_get_term_id($graph);
return unless defined($gid);
my $sth = $self->dbh->prepare('DELETE FROM quad WHERE graph = ?');
$sth->execute($gid);
return;
}
=item C<< begin_transaction >>
Begin a database transaction.
=cut
sub begin_transaction {
# warn 'begin transaction';
my $self = shift;
$self->dbh->begin_work;
}
=item C<< abort_transaction >>
Rollback the current database transaction.
=cut
sub abort_transaction {
# warn 'abort transaction';
my $self = shift;
$self->dbh->rollback;
}
=item C<< end_transaction >>
Commit the current database transaction.
=cut
sub end_transaction {
# warn 'end transaction';
my $self = shift;
$self->dbh->commit;
}
=item C<< begin_bulk_updates >>
Begin a database transaction.
=cut
sub begin_bulk_updates {
my $self = shift;
$self->dbh->begin_work;
}
=item C<< end_bulk_updates >>
Commit the current database transaction.
=cut
sub end_bulk_updates {
my $self = shift;
$self->dbh->commit;
}
( run in 1.944 second using v1.01-cache-2.11-cpan-ceb78f64989 )