Alzabo

 view release on metacpan or  search on metacpan

lib/Alzabo/Runtime/Table.pm  view on Meta::CPAN

L<C<Alzabo::DriverStatement>|Alzabo::Driver/Alzabo::DriverStatement>
object containing the results of the query.  This object has an
interface very similar to the Alzabo cursor interface, and has methods
such as C<next()>, C<next_as_hash()>, etc.

=head2 alias

This returns an object which can be used in joins to allow a
particular table to be involved in the join under multiple aliases.
This allows for self-joins as well as more complex joins involving
multiple aliases to a given table.

The object returned by this method is more or less identical to a
table object in terms of the methods it supports.  This includes
methods that were generated by C<Alzabo::MethodMaker>.

However, B<this object should not be used outside the context of a
join query> because the results will be unpredictable.  In addition,
B<the column objects that the aliased table object returns should also
not be used outside of the context of a join>.

=for pod_merge schema

=for pod_merge name

=for pod_merge column

=for pod_merge columns

=for pod_merge has_column

=for pod_merge primary_key

=for pod_merge primary_key_size

=for pod_merge column_is_primary_key

=for pod_merge foreign_keys

=for pod_merge foreign_keys_by_table

=for pod_merge foreign_keys_by_column

=for pod_merge all_foreign_keys

=for pod_merge index

=for pod_merge has_index

=for pod_merge indexes

=for pod_merge attributes

=for pod_merge has_attribute

=for pod_merge comment

=head1 LAZY COLUMN LOADING

This concept was taken directly from Michael Schwern's Class::DBI
module (credit where it is due).

By default, L<C<Alzabo::Runtime::Row>|Alzabo::Runtime::Row> objects
load all data from the database except blob type columns (columns with
an unbounded length).  This data is stored internally in the object
after being fetched.

If you want to change what data is prefetched, there are two methods
you can use.

The first method,
L<C<set_prefetch()>|Alzabo::Runtime::Table/set_prefetch (Alzabo::Column
objects)>, allows you to specify a list of columns to be fetched
immediately after object creation.  These should be columns that you
expect to use extremely frequently.

The second method, L<C<add_group()>|Alzabo::Runtime::Table/add_group
(Alzabo::Column objects)>, allows you to group columns together.  If
you attempt to fetch one of these columns, then all the columns in the
group will be fetched.  This is useful in cases where you don't often
want certain data, but when you do you need several related pieces.

=head2 Lazy column loading related methods

=head3 set_prefetch (C<Alzabo::Column> objects)

Given a list of column objects, this makes sure that all
L<C<Alzabo::Runtime::Row>|Alzabo::Runtime::Row> objects fetch this
data as soon as they are created.

NOTE: It is pointless (though not an error) to give primary key column
here as these are always prefetched (in a sense).

Throws: L<C<Alzabo::Exception::Params>|Alzabo::Exceptions>

=head3 add_group (C<Alzabo::Column> objects)

Given a list of L<C<Alzabo::Column>|Alzabo::Column> objects, this
method creates a group containing these columns.  This means that if
any column in the group is fetched from the database, then they will
all be fetched.  Otherwise column are always fetched singly.
Currently, a column cannot be part of more than one group.

NOTE: It is pointless to include a column that was given to the
L<C<set_prefetch()>|Alzabo::Runtime::Table/set_prefetch
(Alzabo::Column objects)> method in a group here, as it always fetched
as soon as possible.

Throws: L<C<Alzabo::Exception::Params>|Alzabo::Exceptions>

=head2 prefetch

This method primarily exists for use by the
L<C<Alzabo::Runtime::Row>|Alzabo::Runtime::Row> class.

It returns a list of column names (not objects) that should be
prefetched.

=head2 group_by_column ($column_name)

This method primarily exists for use by the



( run in 0.833 second using v1.01-cache-2.11-cpan-0d23b851a93 )