NAME

SQL::Entity::Table - Database table abstraction

SYNOPSIS

    use SQL::Entity::Table;
    use'SQL::Entity::Column ':all';

    my $table = SQL::Entity::Table->new(
        name => 'emp'
        columns => [sql_column(name => 'empno')]
    );

    my ($sql) = $table->query;

    my $dept = SQL::Entity->new(
        name    => 'dept',
        alias   => 'd',
        columns => [
            sql_column(name => 'deptno'),
            sql_column(name => 'dname')
        ],
    );

    my $emp = SQL::Entity->new(
        name                  => 'emp',
        primary_key           => ['empno'],
        columns               => [
            sql_column(name => 'ename'),
            sql_column(name => 'empno'),
            sql_column(name => 'deptno')
        ],
    );

    $emp->add_to_one_relationships(sql_relationship(
        table     => $dept,
        condition => sql_cond($dept->column('deptno'), '=', $entity->column('deptno'))
    ));

DESCRIPTION

Represents database table definition.

EXPORT

None.

all - exports sql_column method

ATTRIBUTES

name
schema

Table schema name

primary_key
alias
columns
lobs
indexes
order_index

Index name that will be used to enforce order of the result.

METHODS

initialise
unique_columns

Returns list of unique columns

query

Returns sql statement and bind variables, Takes optionally array ref of the requeted columns, condition object, bind_variables reference

count

Retiurn sql and bind variables that returns number of rows for passed in condition,

from_clause

Returns "FROM .... " SQL fragment

from_clause_params

Returns FROM operand " table1 " SQL fragment

from_clause_alias

Returns table alias

select_clause

Returns " SELECT ..." SQL fragment

selectable_columns

Returns list of column that can be used in select clause

insertable_columns

Returns list of column that can be used in insert clause

updatable_columns

Returns list of column that can be used in update clause

query_columns

Returns hash_ref with all columns that belongs to this object.

where_clause

Returns " WHERE ..." SQL fragment

index

Returns order_index object, if order_index is not set then the first index will be seleted.

select_hint_clause

Return hinst cluase that will be placed as SELECT operand

order_by_clause

Returns " ORDER BY ..." SQL fragment

SEE ALSO

SQL::Query SQL::Entity SQL::Entity::Column

COPYRIGHT AND LICENSE

The SQL::Entity::Table module is free software. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.

AUTHOR

Adrian Witas, adrian@webapp.strefa.pl