DBX::Connection - abstracts a connection to a data source


DBX documentation Contained in the DBX distribution.

Index


Code Index:

NAME

Top

DBX::Connection - abstracts a connection to a data source

SYNOPSIS

Top

  use DBX;

  $conn = DBX->mysql("database=test;host=localhost;", "", "");

  $rs = $conn->query("SELECT * FROM test");

DESCRIPTION

Top

DBX::Connection currently provides only one method

query(SQL [, HOW, SQL_PARMS])

query runs SQL on its data source. If HOW is DBX_CURSOR_FORWARD, the returned recordset will only move forward. If HOW is DBX_CURSOR_RANDOM, the returned recordset will be navigable in any direction. However, random-access cursors use considerably more memory and processor time than forward-only cursors.

If the SQL statement contains argument placeholders, the DBI will fill them in with SQL_PARMS.

DEPENDENCIES

Top

Requires DBX and all of its dependencies

SEE ALSO

Top

DBI, DBX, DBX::Recordset

AUTHOR

Top

Bill Atkins, <dbxNOSPAM@batkins.com>

COPYRIGHT AND LICENSE

Top


DBX documentation Contained in the DBX distribution.

package DBX::Connection;

use strict;
use warnings;

use DBI;
use DBX;
use DBX::Recordset;
use DBX::Constants;

require Exporter;

our @ISA = qw(Exporter);
our @EXPORT = qw(DBX_CURSOR_RANDOM DBX_CURSOR_FORWARD);


our $VERSION = '0.1';

sub new
{
	my ($class, $dbh) = @_;

	bless { dbh => $dbh }, $class;
}

sub query
{
	my ($self, $query, $how, @args) = @_;
	my $sth;
	$how ||= DBX_CURSOR_FORWARD;


	$sth = $self->{dbh}->prepare($query);
	$sth->execute(@args);
	DBX::Recordset->new($self->{dbh}, $sth, $how, $query);
}

1;

__END__