DbFramework::Util - DbFramework utility functions |
DbFramework::Util - DbFramework utility functions
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);
DbFramework::Util contains miscellaneous utility functions and acts as a base class for many other DbFramework classes.
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
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
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.
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.
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.
Paul Sharpe <paul@miraclefish.com>
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.
DbFramework::Util - DbFramework utility functions |