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

Name

Object::Relation::Handle::DB - The Object::Relation database store base class

Synopsis

See Object::Relation::Handle.

Description

This class implements the Object::Relation storage API using DBI to communicate with an RDBMS. RDBMS specific behavior is implemented via the Object::Relation::Handle::DB::Pg and Object::Relation::Handle::DBI::SQLite classes.

Public methods

It should be noted that although many methods in this class may be called as class methods, instances are used internally for bookkeeping while parsing the data and assembling information necessary to respond to user messages. Thus, many public class methods instantiate an object prior to doing work.

save

  $store->save($object);

This method saves an object to the data store. It also saves all contained objects to the data store at the same time, all in a single transaction.

If a transaction has been started manually with begin_work, this method does not attempt to start a new transaction.

_begin_work

  $store->_begin_work;

Begins a transaction. No effect if we're already in a transaction.

_commit

  $store->_commit;

Commits a transaction. No effect if we're not in a transaction.

_rollback

  $store->_rollback;

Rolls back an uncommitted transaction. No effect if we're not in a transaction.

search_class

  my $search_class = $store->search_class;
  $store->search_class($search_class);

This is an accessor method for the Object::Relation::Meta::Class object representing the class being searched in the current search. This is usually the first argument to the query method.

Generally, the programmer will know which search class she is working with, but if not, this method is available. Note that it is only available externally if the programmer first creates an instances of store prior to doing a search.

 my $store = Object::Relation::Handle->new;
 my $iter  = $store->query($some_class, name => 'foo');
 my $class = $store->search_class; # returns $some_class

lookup

  my $object = Store->lookup($class_object, $unique_attr, $value);

Returns a single object whose value matches the specified attribute. This method will throw an exception if the attribute does not exist or if it is not unique.

query

  my $iter = $obj_rel_object->query(@search_params);

Returns a Object::Relation::Iterator object containing all objects that match the search params. See Object::Relation::Handle for more information about search params.

squery

  my $iter = $obj_rel_object->squery(@search_params);

Identical to query, but uses string search syntax. This method does not expect the value 'STRING' at the front of a query.

query_uuids

  my @uuids = Store->query_uuids($search_class, \@attributes, \%constraints);
  my $uuids = Store->query_uuids($search_class, \@attributes, \%constraints);

This method will return a list of uuids matching the listed criteria. It takes the same arguments as query. In list context it returns a list. In scalar context it returns an array reference.

squery_uuids

  my @uuids = Store->squery_uuids($search_class, "@attributes", @constraints);
  my $uuids = Store->squery_uuids($search_class, "@attributes", @constraints);

Identical to query_uuids, but uses string search syntax.

count

  my $count = Store->count($class_object, @search_params);

This method takes the same arguments as query. Returns a count of how many rows a similar query will return.

Any final constraints (such as "LIMIT" or "ORDER BY") will be discarded.

Copyright and License

Copyright (c) 2004-2006 Kineticode, Inc. <info@obj_relode.com>

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.