![]() |
![]()
| ![]() |
![]()
NAMEIO::Lambda::DBI - asynchronous DBI DESCRIPTIONThe module implements asynchronous DBI proxy object, that remotes DBI calls using any given file handle, such as stream sockets, pipes, etc. All calls to DBI methods are implemented as method calls to the object, which return lambdas, that shall be subsequently called and awaited for completion. SYNOPSISuse IO::Lambda qw(:all); use IO::Lambda::DBI; use IO::Lambda::Thread qw(new_thread); # use threads as a transport my ($thread, $socket) = new_thread( sub { IO::Lambda::Message::DBI-> new( shift )-> run; }, 1); my $dbi = IO::Lambda::DBI-> new($socket); # execute a query print lambda { context $dbi-> connect('DBI:mysql:database=mysql', '', ''); tail { return "connect error:$_[0]" unless shift; context $dbi-> selectrow_array('SELECT 5 + ?', {}, 2); tail { my ($ok,$result) = @_; return "dbi error:$result" unless $ok; context $dbi-> disconnect; tail { return "select=$result"; }}}}-> wait, "\n"; # finalize $thread-> join; IO::Lambda::DBIAll remoted methods return lambdas of type dbi_result :: () -> ( 1, @result | 0, $error ) where depending on the first returned item in the array, the other items are either DBI method results, or an error. The class handles AUTOLOAD methods as proxy methods, so calls such as "$dbh-> selectrow_array" are perfectly legal.
IO::Lambda::Message::DBIDescendant of "IO::Lambda::Message::Simple". Implements blocking, server side that does the actual calls to the DBI. SEE ALSODBI, eg/dbi.pl. AUTHORDmitry Karasik, <dmitry@karasik.eu.org>.
|