NAME

Oak::IO::DBI - IO routines to exchange data with databases using DBI

DESCRIPTION

This module provides access for exchange data with databases using DBI.

HIERARCHY

Oak::Object

Oak::Persistent

Oak::Component

Oak::IO::DBI

PROPERTIES

datasource

DBI datasorce string, used to create the connection. See perldoc DBI for more information.

username,password,options

DBI options. See DBI documentation for more help.

EVENTS

ev_onConnect

When a connection is openned

ev_onSql

When a sql is executed

ev_onDisconnect

When the database is explicitly disconnected (not on DESTROY)

METHODS

connect

Register the connection for this object. Generates an ev_onConnect event.

Could raise the Oak::IO::DBI::Error::ConnectionFailure exception.

do_sql(SQL)

Prepare, executes and test if successfull. Returns the Sth. Generates an ev_onSql event (passes $sql and $sth to the function called).

Could rause the following exceptions: Oak::Filer::DBI::Error::SQLSyntaxError and Oak::Filer::DBI::Error::SQLExecuteError

quote

Quotes a string, using DBI->quote unless empty, else uses "''".

get_dbh

Returns the DBI object.

disconnect

Called by DESTROY, releases the DBI connection. It disconnects. Generates a ev_onDisconnect event.

begin_work, commit, rollback

Calls the method with the same name at DBI.

EXCEPTION HANDLING

Oak::IO::DBI::Error::ConnectionFailure;

This class is used in the register_connection when it fails

Oak::IO::DBI::Error::SQLSyntaxError;

This class is raised when the sql has wrong syntax

Oak::IO::DBI::Error::SQLExecuteError;

This class is raised when the sql has an error while executing

EXAMPLES

require Oak::IO::DBI;

my $io = new Oak::IO::DBI
 (
  name     => "IODBI",	# mandatory (see Oak::Component)
  dbdriver => "mysql",	# mandatory, any supported by DBI
  database => "mydatabase",	# mandatory
  hostname => "hostname",	# mandatory
  username => "dbusername",	# optional
  password => "userpasswd",	# optional
  options => { DBI OPTIONS },	# optional. A hash reference to DBI options
 )

P.S.: In the case of the automatic creation by an owner object all the
properties will be passed through the RESTORE hash and the OWNER variable.
See Oak::Component.

COPYRIGHT

Copyright (c) 2001 Daniel Ruoso <daniel@ruoso.com> and Rodolfo Sikora <rodolfo@trevas.net>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.