NAME

DBIx::DBO::Table - An OO interface to SQL queries and results. Encapsulates a table in an object.

SYNOPSIS

# Create a Table object
my $table = $dbo->table('my_table');

# Get a column reference
my $column = $table ** 'employee_id';

# Quickly display my employee id
print $table->fetch_value('employee_id', name => 'Vernon');

# Insert a new row into the table
$table->insert(employee_id => 007, name => 'James Bond');

# Remove rows from the table where the name IS NULL
$table->delete(name => undef);

METHODS

dbh

The read-write DBI handle.

rdbh

The read-only DBI handle, or if there is no read-only connection, the read-write DBI handle.

do

$dbo->do($statement)         or die $dbo->dbh->errstr;
$dbo->do($statement, \%attr) or die $dbo->dbh->errstr;
$dbo->do($statement, \%attr, @bind_values) or die ...

This provides access to DBI do method. It defaults to using the read-write DBI handle.

tables

Return a list of DBIx::DBO::Table objects, which will always be this Table object.

column

$t->column($column_name)
$t ** $column_name

Returns the DBO column object for this column.

fetch_value

$t->fetch_value($column, %where)

Fetch the first matching row from the table returning the value in one column.

fetch_hash

$t->fetch_hash(%where)

Fetch the first matching row from the table returning it as a hashref.

fetch_row

$t->fetch_row(%where)

Fetch the first matching row from the table returning it as a Row object.

fetch_column

$t->fetch_column($column, %where)

Fetch all matching rows from the table returning an arrayref of the values in one column.

insert

$t->insert(name => 'Richard', age => 103)

Insert a row into the table.

delete

$t->delete(name => 'Richard', age => 103)

Delete all rows from the table matching the criteria.

config

$table_setting = $dbo->config($option)
$dbo->config($option => $table_setting)

Get or set the DBIx::DBO::Table config settings. When setting an option, the previous value is returned.