Paul Sharpe > DbFramework-1.10 > DbFramework::Util

Download:
DbFramework-1.10.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  1
View/Report Bugs
Source   Latest Release: DbFramework-1.11

NAME ^

DbFramework::Util - DbFramework utility functions

SYNOPSIS ^

  use DbFramework::Util;
  ($user,$password) = DbFramework::Util::get_auth();
  $dbh = DbFramework::Util::get_dbh($dsn,$user,$password);
  $sth = DbFramework::Util::do_sql($dbh,$sql);
  ($user,$password) = DbFramework::Util::get_auth();

  $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.

debug($n)

As a class method sets the class attribute $Debugging to $n. As 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($dsn,$user,$password)

Returns a database handle for the data source name $dsn by connecting using $user and $password.

do_sql($dbh,$sql)

Executes $sql on $dbh and returns a statement handle. This method will die with $h->errstr if prepare() or execute() fails.

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.

syntax highlighting: