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

NAME

DBIx::Class::Row - Basic row methods

SYNOPSIS

DESCRIPTION

This class is responsible for defining and doing basic operations on rows derived from DBIx::Class::ResultSource objects.

METHODS

new

  my $obj = My::Class->new($attrs);

Creates a new row object from column => value mappings passed as a hash ref

insert

  $obj->insert;

Inserts an object into the database if it isn't already in there. Returns the object itself. Requires the object's result source to be set, or the class to have a result_source_instance method. To insert an entirely new object into the database, use create (see "create" in DBIx::Class::ResultSet).

in_storage

  $obj->in_storage; # Get value
  $obj->in_storage(1); # Set value

Indicated whether the object exists as a row in the database or not

update

  $obj->update;

Must be run on an object that is already in the database; issues an SQL UPDATE query to commit any changes to the object to the database if required.

delete

  $obj->delete

Deletes the object from the database. The object is still perfectly usable, but ->in_storage() will now return 0 and the object must reinserted using ->insert() before -E(<gtupdate()> can be used on it. If you delete an object in a class with a has_many relationship, all the related objects will be deleted as well. To turn this behavior off, pass cascade_delete = 0> in the $attr hashref. Any database-level cascade or restrict will take precedence over a DBIx-Class-based cascading delete. See also "delete" in DBIx::Class::ResultSet.

get_column

  my $val = $obj->get_column($col);

Gets a column value from a row object. Currently, does not do any queries; the column must have already been fetched from the database and stored in the object.

has_column_loaded

  if ( $obj->has_column_loaded($col) ) {
     print "$col has been loaded from db";
  }

Returns a true value if the column value has been loaded from the database (or set locally).

get_columns

  my %data = $obj->get_columns;

Does get_column, for all column values at once.

get_dirty_columns

  my %data = $obj->get_dirty_columns;

Identical to get_columns but only returns those that have been changed.

set_column

  $obj->set_column($col => $val);

Sets a column value. If the new value is different from the old one, the column is marked as dirty for when you next call $obj->update.

set_columns

  my $copy = $orig->set_columns({ $col => $val, ... });

Sets more than one column value at once.

copy

  my $copy = $orig->copy({ change => $to, ... });

Inserts a new row with the specified changes.

store_column

  $obj->store_column($col => $val);

Sets a column value without marking it as dirty.

inflate_result

  Class->inflate_result($result_source, \%me, \%prefetch?)

Called by ResultSet to inflate a result from storage

update_or_insert

  $obj->update_or_insert

Updates the object if it's already in the db, else inserts it.

insert_or_update

  $obj->insert_or_update

Alias for "update_or_insert"

is_changed

  my @changed_col_names = $obj->is_changed();
  if ($obj->is_changed()) { ... }

In array context returns a list of columns with uncommited changes, or in scalar context returns a true value if there are uncommitted changes.

is_column_changed

  if ($obj->is_column_changed('col')) { ... }

Returns a true value if the column has uncommitted changes.

result_source

  my $resultsource = $object->result_source;

Accessor to the ResultSource this object was created from

register_column

  $column_info = { .... };
  $class->register_column($column_name, $column_info);

Registers a column on the class. If the column_info has an 'accessor' key, creates an accessor named after the value if defined; if there is no such key, creates an accessor with the same name as the column

The column_info attributes are described in "add_columns" in DBIx::Class::ResultSource

throw_exception

See Schema's throw_exception.

AUTHORS

Matt S. Trout <mst@shadowcatsystems.co.uk>

LICENSE

You may distribute this code under the same terms as Perl itself.