Oryx::DBI::Util - abstract base class for Oryx DBI utilities
Oryx::DBI::Util represents an interface to be implemented in order to add support for additional RDBMS'. The following methods must be implemented:
Returns a true value if the column named $column exists in table named $table in database $dbh.
$column
$table
$dbh
Adds a column to the table named $table named $colname with type $coltype in database $dbh.
$colname
$coltype
Removes the column named $$colname from the table named $table in database $dbh.
Returns a true value if the table $table exists in $dbh.
Creates a table named $table with columns @columns having types @types in database $dbh.
@columns
@types
Drops the table named $table in database $dbh.
Given an Oryx primitive type $type and an optional size, $size, this method returns the SQL type for the current connection.
$type
$size
Returns what should be the last insert ID used for table $table in database $dbh. However, due to some DBD driver limitations, this method should not be used except to check the last insert ID of an insertion that happened in a statement executed immediately previous to calling this method.
In order to allow Oryx to store data in a database other than those already supported, one need only provide an implementation for a utility class for use with the appropriate driver.
The utility class should inherit from Oryx::DBI::Util and should provide implementations appropriate for all of the methods documented here. Since DBI and standard SQL make the implementation very similar across databases, many of the methods are defined here already. You should examine this class for the default implementations to see if they need to be overridden. You will, at the very least, need to provide either an array named %SQL_TYPES in your class or and implementation of type2sql():
%SQL_TYPES
type2sql()
# Taken from Oryx::DBI::Util::Pg at the time of writing our %SQL_TYPES = ( 'Oid' => 'serial PRIMARY KEY', 'Integer' => 'integer', 'String' => 'varchar', 'Text' => 'text', 'Binary' => 'bytea', 'Float' => 'numeric', 'Boolean' => 'integer', 'DateTime' => 'timestamp', );
You may also want to examine the code found in the utilities already provided. As of this writing, this includes Oryx::DBI::Util::Pg for PostgreSQL accessed via DBD::Pg, Oryx::DBI::Util::mysql for MySQL accessed via DBD::mysql, and Oryx::DBI::Util::SQLite for SQLite accessed via DBD::SQLite.
Oryx::DBI, Oryx::DBI::Class, Oryx::DBI::Util::Pg, Oryx::DBI::Util::mysql, Oryx::DBI::Util::SQLite, DBI
Richard Hundt <richard NO SPAM AT protea-systems.com>
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
Copyright (C) 2005 Richard Hundt.
This library is free software and may be used under the same terms as Perl itself.
To install Oryx, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Oryx
CPAN shell
perl -MCPAN -e shell install Oryx
For more information on module installation, please visit the detailed CPAN module installation guide.