NAME

DbFramework::Util - DbFramework utility functions

SYNOPSIS

use DbFramework::Util;
($user,$password) = DbFramework::Util::get_auth();
$dbh = DbFramework::Util::get_dbh($db,$host,$port,$user,$password);
$object->get_db($dbh);
$object->debug($n);

DESCRIPTION

DbFramework::Util contains miscellaneous utility functions and acts as a base class for many other DbFramework classes.

BASE CLASS METHODS

AUTOLOAD()

AUTOLOAD() provides default accessor methods (apart from DESTROY()) for any of its subclasses. For AUTOLOAD() to catch calls to these methods objects must be implemented as an anonymous hash. Object attributes must

*) have UPPER CASE names
*) have keys in attribute _PERMITTED (an anonymous hash)

The name accessor method is the name of the attribute in lower case. The 'set' versions of these accessor methods require a single scalar argument (which could of course be a reference.) Both 'set' and 'get' versions return the attribute's value.

Special Attributes

/_L$/

Attribute names matching the pattern /_L$/ will be treated as arrayrefs. These accessors require an arrayref as an argument. If the attribute is defined they return the arrayref, otherwise they return an empty arrayref.

A method *_l_add(@foo) can be called on this type of attribute to add the elements in @foo to the array. If the attribute is defined they return the arrayref, otherwise they return an empty arrayref.

/_H$/

Attribute names matching the pattern /_H$/ will be treated as hashrefs. These accessors require a reference to an array containing key/value pairs. If the attribute is defined they return the hashref, otherwise they return an empty hashref.

A method *_h_byname(@list) can be called on this type of attribute. These methods will return a list which is the hash slice of the _H attribute value over @list or an empty list if the attribute is undefined.

A method *_h_add(\%foo) can be called on this type of attribute to add the elements in %foo to the hash. If the attribute is defined they return the hashref, otherwise they return an empty hashref. =back

debug($n)

As a class method, sets the class attribute $Debugging to $n. Aa an object method, sets the object attribute $_DEBUG to $n.

UTILITY FUNCTIONS

get_auth()

Read ($user,$password) from standard input with no echo when entering password.

get_dbh($db,$host,$port,$user,$password)

Return a Mysql database handle for $db (and optionally $host and $port) by connecting using $user and $password.

get_db($dbh)

Get the name of the database from the DBI database handle $dbh.

AUTHOR

Paul Sharpe <paul@miraclefish.com>

COPYRIGHT

Copyright (c) 1997,1998 Paul Sharpe. England. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 70:

'=item' outside of any '=over'

Around line 131:

You forgot a '=back' before '=head2'