The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Alzabo::Runtime::Row - Row objects

SYNOPSIS

  use Alzabo::Runtime::Row;

  ... or ...

  use Alzabo::Runtime::Row qw(MyCaching::Class);

DESCRIPTION

These objects represent actual rows from the database containing actual data. They can be created via their new method or via an Alzabo::Runtime::Table object.

Alzabo::Runtime::Row import METHOD

This method is called when you use this class. You can pass a string to the module via the use function. This string is assumed to be the name of a class which does caching and that has a specific interface that Alzabo::Runtime::Row expects (see the CACHING CLASSES section for more details). The Alzabo::Runtime::Row class will attempt to load the class you have specified and will then use it for all future caching operations.

The default is to use the Alzabo::ObjectCache class. If you are programming in a persistent environment it is highly recommended that you read "CAVEATS" in Alzabo::ObjectCache for more information on how that class works.

METHODS

  • new

    Takes the following parameters:

  • -- table => Alzabo::Runtime::Row object

  • -- id => (see below)

  • -- no_cache => 0 or 1

    The 'id' parameter may be one of two things. If the table has only a single column primary key, it can be a simple scalar with the value of that primary key for this row.

    If the primary key is more than one column than it must be a hash reference containing column names and values such as:

      { pk_column1 => 1,
        pk_column2 => 'foo' }

    Returns a new row object. If you specified a caching class it will attempt to retrieve the row from the cache first unless the 'no_cache' parameter is true. If no object matches these values then an exception _will_ be thrown.

    Setting the 'no_cache' parameter to true causes this particular row object to not interact with the caching class at all. This can be useful if you know you will be creating a very large number of row objects all at once that you have no intention of re-using any time soon and your cache class uses an LRU type of cache or something similar.

    If your cache class attempts to synchronize itself across multiple processes, then it is highly recommended that you not do any operations that change data in the database with objects that were created with this parameter as it will probably cause a big nasty mess. Don't say I didn't warn you.

    Exceptions:

     AlzaboException - attempt to create a row for a table without a
     primary key.
     AlzaboNoSuchRowException - no row matched the primary key values
     given

    item * get_data

    Tells the row object to connect to the database and fetch the data for the row matching this row's primary key values. If a cache class is specified it attempts to fetch the data from the cache first.

    Exceptions:

     AlzaboNoSuchRowException - no row in the RDBMS matches this object's
     primary key value(s).
  • select (@list_of_column_names)

    In list context, returns a list of values matching the specified columns. In scalar context it returns only a single value (the first column specified).

    Exceptions:

     AlzaboCacheException - the row this object represents has been
     deleted from the database.

    item * update (%hash_of_columns_and_values)

    Given a hash of columns and values, attempts to update the database to and the object to represent these new values.

    Exceptions:

     AlzaboCacheException - the row this object represents has been
     deleted from the database.
     AlzaboCacheException - the row has expired in the cache (something
     else updated the object before you did).
     AlzaboException - attempt to change the value of a primary key
     column. Instead, delete the row object and create a new one.
     AlzaboException - attempt to set a column to NULL which cannot be NULL.
     AlzaboReferentialIntegrity - something you tried to do violates
     referential integrity.
  • delete

    Deletes the row from the RDBMS and the cache, if it exists.

    Exceptions:

     AlzaboCacheException - the row this object represents has been
     deleted from the database.
     AlzaboCacheException - the row has expired in the cache (something
     else updated the object before you did).
  • id

    Returns the row's id value as a string. This can be passed to the Alzabo::Runtime::Table row_by_id method to recreate the row later.

  • table

    Returns the table object that this row belongs to.

  • rows_by_foreign_key

    Takes the following parameters:

  • -- foreign_key => Alzabo::ForeignKey object

    Given a foreign key object, this method returns a Alzabo::Runtime::RowCursor object for the rows in the table that the relationship is _to_, based on the value of the relevant column in the current row.

    All other parameters given will be passed directly to the Alzabo::Runtime::Row new method (such as the 'no_cache' paremeter).

AUTHOR

Dave Rolsky, <autarch@urth.org>

6 POD Errors

The following errors were encountered while parsing the POD:

Around line 411:

'=item' outside of any '=over'

Around line 415:

Expected '=item *'

Around line 417:

Expected '=item *'

Around line 419:

Expected '=item *'

Around line 519:

Expected '=item *'

Around line 529:

You forgot a '=back' before '=head1'