On Thursday, January 3, 2002, at 08:11 AM, Tim Bunce wrote:
>
> People could, if they want, think of the changes I'm proposing as
> being suited to providing simpler implementations of modules like
> DBIx::Abstract, DBIx::AbstractLite, DBIx::Broker, DBIx::Cache,
> DBIx::DWIW etc.
>
>
yeah, all of those modules were written as packages with methods.
the other way that a Perl module which requires DBI database
handles to do its work is exemplified by PApp::SQL, also on CPAN.
What he does instead is something like this:
$sth = sql_exec [dbh,] [bind-vals...,] "sql-statement",
and then if no dbh is given, then he looks in the current package
for a variable called $DBH and then he looks in
$PApp::SQL::DBH for such a variable. The first one he finds he
uses as the database handle for the call.
And I might also mention that I recently took all of the DBI
convenience functions in the AnyDBD distribution and rewrote them
to use a similar $dbh search protocol. It is available on CPAN as
DBIx.... that's right, plain DBIx.