NAME

POE::Component::LaDBI::Request - Class to encapsulate LaDBI requests to be executed by POE::Component::LaDBI::Engine.

SYNOPSIS

Excuse the vulgarities, I was tired and maybe even a little drunk ;).

  use POE::Component::LaDBI::Request;

  $dsn = 'dbi:Sybase:server=biteme;hostname=sybdb.biteme.com;database=biteme',
  $user = 'pimple';
  $passwd = 'oNMyaSS';

  $req = POE::Component::LaDBI::Request->new(Cmd  => 'connect',
					     Data => [$dsn, $user, $passwd]);

  $eng = POE::Component::LaDBI::Engine->new();

  $resp = $eng->request( $req );

  die "connect failed" unless $resp->code eq 'OK';

  $dbh_id = $resp->handle_id;

  $sql = 'SELECT * FROM candidates WHERE jaws = ? AND willingness = ?'

  $req = POE::Component::LaDBI::Request->new(Cmd      => 'prepare',
					     HandleId => $dbh_id  ,
					     Data     => [$sql]   );

  $resp = $eng->request( $req );

  die "prepare failed" unless $resp->code eq 'OK';

  $sth_id = $resp->handle_id;

  $req = POE::Component::LaDBI::Request->new(Cmd      => 'execute',
					     HandleId => $sth_id  ,
					     Data     => ['WEAK','HIGH']);

  $resp = $eng->request( $req );

  die "execute failed" unless $resp->code eq 'OK';

  $req = POE::Component::LaDBI::Request->new(Cmd      => 'rows',
					     HandleId => $sth_id);

  $resp = $eng->request( $req );

  die "rows failed" unless $resp->code eq 'OK';

  $nr_rows = $resp->data();

  $req = POE::Component::LaDBI::Request->new(Cmd      => 'fetchrow',
					     HandleId => $sth_id);

  for ($i=0; $i < $nr_rows; $i++) {

     $resp = $eng->request( $resp );

     die "fetchrow failed" unless $resp->code eq 'OK';

     $row = $resp->data();

     print "row[$i]: ", join("\t", @$row), "\n";

  }

DESCRIPTION

$req = POE::Component::LaDBI::Request->new()

Upon instantiation a request id is allocated to represent this request. This cookie is available as $req-id>.

Args:

For the keys, capitalization does not matter. Internally the keys are lowercased.

Cmd

Required.

The command to execute. Only a subset of DBI basic commands implemented.

The value must be in all uppercase.

So far they are:

CONNECT     	    ->   DBI->connect
DISCONNECT  	    ->   $dbh->disconnect
PREPARE     	    ->   $sth->prepare
FINISH      	    ->   $sth->finish
EXECUTE     	    ->   $sth->execute
ROWS        	    ->   $sth->rows
FETCHROW    	    ->   $sth->fetchrow
FETCHROW_HASH    ->   $sth->fetchrow_hash
FETCHALL    	    ->   $sth->fetchall
FETCHALL_HASH    ->   $sth->fetchall_hash
PING        	    ->   $dbh->ping
DO          	    ->   $dbh->do
BEGIN_WORK       ->   $dbh->begin_work
COMMIT      	    ->   $dbh->commit
ROLLBACK    	    ->   $dbh->rollback
SELECTALL        ->   $dbh->selectall
SELECTALL_HASH   ->   $dbh->selectall_hash
SELECTCOL        ->   $dbh->selectcol
SELECTROW        ->   $dbh->selectrow
QUOTE            ->   $dbh->quote
HandleId

For some commands it is required. They are:

DISCONNECT
PREPARE
FINISH
EXECUTE
ROWS
FETCHROW
FETCHROW_HASH
FETCHALL
PING
DO
BEGIN_WORK
COMMIT
ROLLBACK
SELECTALL
SELECTALL_HASH
SELECTCOL
SELECTROW
QUOTE
Data

For some commands it is required. They are:

CONNECT
PREPARE
DO
FETCHALL_HASH
SELECTALL
SELECTALL_HASH
SELECTCOL
SELECTROW
QUOTE

No Data field is allowed for:

DISCONNECT
ROWS
FETCHROW
FETCHROW_HASH
BEGIN_WORK
COMMIT
ROLLBACK
$req->cmd

Set/Get accessor function.

$req->data

Set/Get accessor function.

$req->handle_id

Set/Get accessor function.

$req->id

Get accessor function.

EXPORT

None by default.

AUTHOR

Sean Egan, <seanegan:bigfoot_com>

SEE ALSO

perl, POE::Component::LaDBI::Response, POE::Component::LaDBI::Engine.