View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Dave Rolsky > Fey-DBIManager > Fey::DBIManager::Source



Annotate this POD


Open  0
View/Report Bugs
Module Version: 0.16   Source  


Fey::DBIManager::Source - Wraps a single DBI handle


version 0.16


  my $source = Fey::DBIManager::Source->new( dbh => $dbh );

  my $dbh = $source->dbh();


A Fey::DBIManager::Source object provides a wrapper around a DBI handle which does things like ensure that handles are recreated properly after a fork.

A source can be created from an existing DBI handle, or from parameters such as the dsn and authentication info.


This class provides the following methods:


Creates a new Fey::DBIManager::Source object. This method accepts a number of parameters.


Returns a database handle for the source. If you did not pass a handle to the constructor, this may create a new handle. If auto_refresh is true, this may cause a new handle to be created. See "HANDLE FRESHNESS" for more details.






These methods simply return the value of the specified attribute.


This method returns attributes hash reference for the source. This will be a combination of any attributes passed to the constructor plus the "REQUIRED ATTRIBUTES".


Returns a boolean indicating whether or not the database to which the source connects supports nested transactions. It does this by trying to issue two calls to $dbh->begin_work() followed by two calls to $dbh->rollback() (in an eval block).


Returns a new source which is a clone of the original. If no name is provided, it is created as "Clone of <original name>". The cloned source does not share the original's database handle.

Any arguments passed to this method are passed to the constructor when creating the clone.


In order to provide consistency for Fey::ORM, sources enforce a set of standard attributes on DBI handles:


If auto_refresh is true for a source, then every call to $source->dbh() incurs the cost of a "freshness" check. The upside of this is that it will just work in the face of forks, threading, and lost connections.

First, we check to see if the pid has changed since the handle was created. If it has, we set InactiveDestroy to true in the handle before making a new handle. If the thread has changed, we just make a new handle.

Next, we check $dbh->{Active] and, if this is false, we disconnect the handle.

Finally, we check that the handle has responded to $dbh->ping() within the past $source->ping_interval() seconds. If it hasn't, we call $dbh->ping() and, if it returns false, we disconnect the handle.

If the handle is not fresh, a new one is created.


Please report any bugs or feature requests to, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


Dave Rolsky <>


This software is Copyright (c) 2011 by Dave Rolsky.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)
syntax highlighting: