NAME

Basset::DB::Table::View - used to define virtual views to your objects.

AUTHOR

Jim Thomason, jim@jimandkoka.com

SYNOPSIS

For example,

 my $table = Basset::DB::Table::View->new(
        'name'                          => 'user',
        'primary_column'        => 'id',
        'select_query' => <<'   eSQL',
                select
                        user.id,
                        name,
                        count(*) as movies
                from
                        user, movies
                where
                        user.id = movies.user
                        and user.id = ?
                group by
                        user.id, name
        eSQL
        'definition'            => {
                'id'            => 'SQL_INTEGER',
                'name'          => 'SQL_VARCHAR',
                'movies'        => 'SQL_INTEGER',
        }
 );
 
 Some::Class->add_primarytable($table);
 
 my $object = Some::Class->load(1);     #load by user 1
 print $object->id, "\n"; #id (user id)
 print $object->name, "\n"; #"Jack Sprat"
 print $object->movies, "\n"; #145 (he owns 145 movies)

DESCRIPTION

Basset::DB::Table::View provides an abstract and consistent location for defining database views. Normally, your objects are mapped to tables (most frequently in a 1-1 manner), but sometimes it's convenient to hide a view of data behind an object. This way you can access a complex data query as if it were an object.

Basset::DB::Table::View as your primary table allows you to do that.

Naturally, by virtue of the fact that these are potentially complex queries, objects that use view tables are read-only.

ATTRIBUTES

    select_query

    In view tables, the select_query is an attribute, not a method. You should explicitly define the select query that is used by this table view.

     $table->select_query('select * from somewhere');

1 POD Error

The following errors were encountered while parsing the POD:

Around line 76:

You can't have =items (as at line 82) unless the first thing after the =over is an =item