DBD-AnyData2
view release on metacpan or search on metacpan
lib/DBD/AnyData2.pm view on Meta::CPAN
$meta->{ad2h} and undef $meta->{ad2h};
$self->SUPER::DESTROY();
}
########################
package DBD::AnyData2::AdvancedChangingTable;
########################
@DBD::AnyData2::AdvancedChangingTable::ISA = qw(DBD::AnyData2::Table);
use Carp qw/croak/;
sub capability($)
{
my ( $self, $capname ) = @_;
exists $self->{capabilities}->{$capname} and return $self->{capabilities}->{$capname};
my $meta = $self->{meta};
$capname eq "insert_new_row"
and $self->{capabilities}->{insert_new_row} = $meta->{ad2h}->can("insert_new_row");
$capname eq "delete_one_row"
and $self->{capabilities}->{delete_one_row} = $meta->{ad2h}->can("delete_one_row");
$capname eq "delete_current_row"
and $self->{capabilities}->{delete_current_row} =
( $meta->{ad2h}->can("delete_current_row") and $meta->{ad2h}->capability("inplace_delete") );
$capname eq "update_one_row"
and $self->{capabilities}->{update_one_row} = $meta->{ad2h}->can("update_one_row");
$capname eq "update_current_row"
and $self->{capabilities}->{update_current_row} =
( $meta->{ad2h}->can("update_current_row") and $meta->{ad2h}->capability("inplace_update") );
$capname eq "update_specific_row"
and $self->{capabilities}->{update_specific_row} = $meta->{ad2h}->can("update_specific_row");
$self->SUPER::capability($capname);
}
# you must define push_row except insert_new_row and update_specific_row is defined
# it is called on inserts and updates as primitive
#
sub insert_new_row ($$$)
{
my ( $self, $data, $row_aryref ) = @_;
my $meta = $self->{meta};
my $ncols = scalar( @{ $meta->{col_names} } );
my $nitems = scalar( @{$row_aryref} );
$ncols == $nitems
or croak "You tried to insert $nitems, but table is created with $ncols columns";
$meta->{ad2h}->insert_new_row($row_aryref);
}
sub delete_one_row ($$$)
{
my ( $self, $data, $aryref ) = @_;
my $meta = $self->{meta};
$meta->{ad2h}->delete_one_row($aryref);
}
sub update_one_row ($$$)
{
my ( $self, $data, $aryref ) = @_;
my $meta = $self->{meta};
# we don't know the key item
$meta->{ad2h}->update_one_row($aryref);
}
sub update_specific_row ($$$$)
{
my ( $self, $data, $aryref, $origary ) = @_;
my $meta = $self->{meta};
return unless ( defined $origary->[0] );
$origary->[0] eq $aryref->[0] or croak "Updating a row with new transaction ID is not supported. DELETE and INSERT instead.";
my $row = ( ref($aryref) eq 'ARRAY' ) ? $aryref : [$aryref];
$meta->{ad2h}->update_specific_row($aryref, $origary);
}
1;
__END__
=pod
=head1 NAME
DBD::AnyData2 - a DBI driver for AnyData2
=head1 SYNOPSIS
use DBI;
$dbh = DBI->connect('dbi:AnyData2:');
$dbh = DBI->connect('DBI:AnyData2(RaiseError=1):');
# or
$dbh = DBI->connect('dbi:AnyData2:', undef, undef);
$dbh = DBI->connect('dbi:AnyData2:', undef, undef, {
...
});
and other variations on connect() as shown in the L<DBI> docs,
L<DBI::DBD::SqlEngine metadata|DBI::DBD::SqlEngine/Metadata> and L</Metadata>
shown below.
Use standard DBI prepare, execute, fetch, placeholders, etc.,
see L<QUICK START> for an example.
=head1 DESCRIPTION
DBD::AnyData2 is a database management system that works right out of the
box. If you have a standard installation of Perl and DBI you can begin
creating, accessing, and modifying simple database tables without any
further modules.
=head1 QUICK START
...
=head1 BUGS AND LIMITATIONS
=head1 GETTING HELP, MAKING SUGGESTIONS, AND REPORTING BUGS
If you need help installing or using DBD::AnyData2, please write to the DBI
users mailing list at dbi-users@perl.org or to the
comp.lang.perl.modules newsgroup on usenet. I cannot always answer
every question quickly but there are many on the mailing list or in
the newsgroup who can.
DBD developers for DBD's which rely on DBI::DBD::SqlEngine or DBD::AnyData2 or use
one of them as an example are suggested to join the DBI developers
( run in 0.991 second using v1.01-cache-2.11-cpan-39bf76dae61 )