Mark Lawrence > SQL-DB > SQL::DB::Schema

Download:
SQL-DB-0.971.0.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  2
View/Report Bugs
Module Version: 0.971.0   Source  

NAME ^

SQL::DB::Schema - Table and column definitions for SQL::DB

VERSION ^

0.971.0. Development release.

SYNOPSIS ^

    use SQL::DB::Schema;

    my $schema = SQL::DB::Schema->new( name => 'myschema' );

    $schema->define(@table_1_definition);
    $schema->define(@table_2_definition);
    $schema->define(@table_3_definition);
    # ...
    $schema->define(@table_N_definition);
    
    my ($itable_1, $itable_3) = $schema->irows(qw/table_1, table_3/)
    my ($utable_1, $utable_3) = $schema->urows(qw/table_1, table_3/)
    my ($stable_1, $stable_2) = $schema->srows(qw/table_1, table_2/)

DESCRIPTION ^

SQL::DB::Schema objects hold the table and column definitions used by SQL::DB for creating SQL queries.

The SYNOPSIS and this documentation show how this module is used but you should never write such code by hand. Schema information is either automatically retrieved by SQL::DB at run-time or pre-generated using deployed_table_info() from SQL::DBx::Deploy.

CONSTRUCTOR ^

new( name => $name ) -> SQL::DB::Schema

Create a new schema object with the following parameters:

name

The name of the schema. The name is required and should be unique.

ATTRIBUTES ^

name

The name of the schema as given to the constructor.

package_root

The name prefix for internally generated classes.

METHODS ^

define( \@column_info )

Add table/column information to the schema. The \@column_info array-reference must be the same as the structure returned from a DBI "column_info()" call. This method will confess if duplicate column information is given.

not_known(@tables) -> @not_known

Returns the @tables which are not known in the schema.

irows( $table, [ $table2 ] ) -> @CODErefs

Returns coderefs representing $table(s). Each coderef called with column names returns a string suitable for an INSERT operation. These coderefs can be used in SQL::DB's "do()" method (for INSERT queries). Raises an exception if a non-existing table is requested.

urows( $table, [ $table2 ] ) -> @SQL::DB::Expr

Returns objects representing abstract rows from $table(s). Each object has a method for each column in the table. These urow objects can be used in SQL::DB's "do()" method (UPDATE or DELETE queries). Raises an exception if a non-existing table is requested.

srows( $table, [ $table2 ] ) -> @SQL::DB::Expr

Returns objects representing abstract rows from $table(s). Each object has a method for each column in the table. These srow objects can be used in SQL::DB "fetch()" and "fetch1()" methods (for SELECT queries). Raises an exception if a non-existing table is requested.

SEE ALSO ^

SQL::DBx::Deploy

AUTHOR ^

Mark Lawrence <nomad@null.net>

COPYRIGHT AND LICENSE ^

Copyright 2007-2011 Mark Lawrence <nomad@null.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

syntax highlighting: