Alzabo
view release on metacpan or search on metacpan
lib/Alzabo/Driver.pm view on Meta::CPAN
statement, if any.
=head1 SUBCLASSING Alzabo::Driver
To create a subclass of C<Alzabo::Driver> for your particular RDBMS is
fairly simple. First of all, there must be a C<DBD::*> driver for it,
as C<Alzabo::Driver> is built on top of C<DBI>.
Here's a sample header to the module using a fictional RDBMS called FooDB:
package Alzabo::Driver::FooDB;
use strict;
use vars qw($VERSION);
use Alzabo::Driver;
use DBI;
use DBD::FooDB;
use base qw(Alzabo::Driver);
The next step is to implement a C<new> method and the methods listed
under L<Virtual Methods>. The C<new> method should look a bit like
this:
1: sub new
2: {
3: my $proto = shift;
4: my $class = ref $proto || $proto;
5: my %p = @_;
6:
7: my $self = bless {}, $class;
8:
9: return $self;
10: }
The hash %p contains any values passed to the
C<Alzabo::Driver-E<gt>new> method by its caller.
Lines 1-7 should probably be copied verbatim into your own C<new>
method. Line 5 can be deleted if you don't need to look at the
parameters.
Look at the included C<Alzabo::Driver> subclasses for examples. Feel
free to contact me for further help if you get stuck. Please tell me
what database you're attempting to implement, what its DBD::* driver
is, and include the code you've written so far.
=head2 Virtual Methods
The following methods are not implemented in C<Alzabo::Driver> itself
and must be implemented in a subclass.
=head3 Parameters for connect(), create_database(), and drop_database()
=over 4
=item * user => $db_username
=item * password => $db_pw
=item * host => $hostname
=item * port => $port
=back
All of these default to undef. See the appropriate DBD driver
documentation for more details.
After the driver is created, it will have access to its associated
schema object in C<< $self->{schema} >>.
=head2 connect
Some drivers may accept or require more arguments than specified
above.
Note that C<Alzabo::Driver> subclasses are not expected to cache
connections. If you want to do this please use C<Apache::DBI> under
mod_perl or don't call C<connect()> more than once per process.
=head2 create_database
Attempts to create a new database for the schema attached to the
driver. Some drivers may accept or require more arguments than
specified above.
=head2 drop_database
Attempts to drop the database for the schema attached to the driver.
=head2 schemas
Returns a list of schemas in the specified RDBMS. This method may
accept some or all of the parameters which can be given to
C<connect()>.
=head2 supports_referential_integrity
Should return a boolean value indicating whether or not the RDBMS
supports referential integrity constraints.
=head2 next_sequence_number (C<Alzabo::Column> object)
This method is expected to return the value of the next sequence
number based on a column object. For some databases (MySQL, for
example), the appropriate value is C<undef>. This is accounted for in
the Alzabo code that calls this method.
=head2 begin_work
Notify Alzabo that you wish to start a transaction.
=head2 rollback
Rolls back the current transaction.
=head2 commit
( run in 0.673 second using v1.01-cache-2.11-cpan-5a3173703d6 )