DBIx::DBO2::Table - A table in a datasource
my $sqldb = DBIx::SQLEngine->new( ... ); my $table = DBIx::DBO2::Table->new( name => 'foo', datasource => $ds ); my $row = $table->fetch_id(1); my $row_ary = $table->fetch_select( criteria => { status => 2 } );
The DBIx::DBO2::Table class represents database tables accessible via DBIx::SQLEngine.
A table acts as an interface to a particular set of data, uniquely identfied by the datasource that it connects to and the b<name> of the table.
It facilitates generation of SQL queries that operate on the named table.
Each table can retrieve and cache a ColumnSet containing information about the name and type of the columns in the table. Column information is loaded from the storage as needed, but if you are creating a new table you must provide the definition.
Create one Table for each underlying database table you will use.
You are expected to provde the name and datasource or datasource_name arguments. (Standard::Hash:new)
Required. Identifies this table in the DataSource.
$table->name($string) $table->name() : $string
Set and get the table name. (Template::Hash:string)
Required. The DataSource provides the DBI connection and SQL execution capabilities required to talk to the remote data storage.
Refers to our current DBIx::SQLEngine. (Standard::Hash:object)
$table->datasource_name () : $name
Get the name of the current datasource.
$table->datasource_name ($name) : ()
Attempt to find a datasource with the given name, and store it as our datasource reference.
$table->insert_row ( $row_hash ) : ()
Adds the provided row by executing a SQL insert statement.
$table->insert_rows ( $row_hash_ary ) : ()
Insert each of the rows from the provided array into the table.
$table->fetch_all () : $row_hash_array
Retrieve all of the rows from the datasource.
$table->fetch ( CRITERIA, SORTING ) : $row_hash_array
Return rows from the table that match the provided criteria, and in the requested order, by executing a SQL select statement.
$table->fetch_id ( $PRIMARY_KEY ) : $row
Fetch the row with the specified ID.
$table->update_row ( $row_hash ) : ()
Update this existing row based on its primary key.
$table->update_where ( CRITERIA, $changes_hash ) : ()
Make changes as indicated in changes hash to all rows that meet criteria
$table->delete_all () : ()
Delete all of the rows from table.
$table->delete_where ( $criteria ) : ()
$table->delete_row ( $row_hash ) : ()
Deletes the provided row from the table.
$table->delete_id ( $PRIMARY_KEY ) : ()
Deletes the row with the provided ID.
$table->count_rows ( CRITERIA ) : $number
Return the number of rows in the table. If called with criteria, returns the number of matching rows.
$table->count_rows ( $colname, CRITERIA ) : $number
Returns the largest value in the named column.
$table->detect_datasource : $flag
Detects whether the SQL database is avaialable by attempting to connect.
$table->table_exists : $flag
Checks to see if the table exists in the SQL database by attempting to retrieve its columns.
$table->columnset () : $columnset
Returns the current columnset, if any.
$table->get_columnset () : $columnset
Returns the current columnset, or runs a trivial query to detect the columns in the DataSource. If the table doesn't exist, the columnset will be empty.
$table->columns () : @columns
Return the column objects from the current columnset.
$table->column_names () : @column_names
Return the names of the columns, in order.
$table->column_named ( $name ) : $column
Return the column info object for the specicifcally named column.
$table->table_create () $table->table_create ( $column_ary )
$table->table_drop ()
$table->table_ensure_exists ( $column_ary )
Create the table's remote storage if it does not already exist.
$table->table_recreate ()
Remove and then recreate the table's remote storage.
See DBIx::DBO2 for an overview of this framework.
To install DBIx::DBO2, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::DBO2
CPAN shell
perl -MCPAN -e shell install DBIx::DBO2
For more information on module installation, please visit the detailed CPAN module installation guide.