CatalystX::CRUD::Model::RDBO - Rose::DB::Object CRUD


CatalystX-CRUD-Model-RDBO documentation  | view source Contained in the CatalystX-CRUD-Model-RDBO distribution.

Index


NAME

Top

CatalystX::CRUD::Model::RDBO - Rose::DB::Object CRUD

SYNOPSIS

Top

 package MyApp::Model::Foo;
 use base qw( CatalystX::CRUD::Model::RDBO );
 __PACKAGE__->config( 
            name                => 'My::RDBO::Foo', 
            manager             => 'My::RDBO::Foo::Manager',
            load_with           => [qw( bar )],
            related_load_with   => {
                bars => ['doof']
            },
            page_size           => 50,
            );
 1;

DESCRIPTION

Top

CatalystX::CRUD::Model::RDBO is a CatalystX::CRUD implementation for Rose::DB::Object.

CONFIGURATION

Top

The config options can be set as in the SYNOPSIS example.

METHODS

Top

name

The name of the Rose::DB::Object-based class that the model represents. Accessible via name() or config->{name}.

manager

If manager is not defined in config(), the Xsetup() method will attempt to load a class named with the name value from config() with ::Manager appended. This assumes the namespace convention of Rose::DB::Object::Manager.

If there is no such module in your @INC path, then the fall-back default is Rose::DB::Object::Manager.

load_with

The value of load_with should be an array ref of relationship names. The array ref is passed into all the Manager get_objects* methods as the with_objects value.

Xsetup

Implements the required Xsetup() method. Instatiates the model's name() and manager() values based on config().

new_object( @param )

Returns a CatalystX::CRUD::Object::RDBO object.

fetch( @params )

If present, @params is passed directly to name()'s new() method, and is expected to be an array of key/value pairs. Then the load() method is called on the resulting object.

If @params are not present, the new() object is simply returned, which is equivalent to calling new_object().

All the methods called within fetch() are wrapped in an eval() and sanity checked afterwards. If there are any errors, throw_error() is called.

Example:

 my $foo = $c->model('Foo')->fetch( id => 1234 );
 if (@{ $c->error })
 {
    # do something to deal with the error
 }

NOTE: If the object's presence in the database is questionable, your controller code may want to use new_object() and then call load_speculative() yourself. Example:

 my $foo = $c->model('Foo')->new_object( id => 1234 );
 $foo->load_speculative;
 if ($foo->not_found)
 {
   # do something
 }

search( @params )

@params is passed directly to the Manager get_objects() method. See the Rose::DB::Object::Manager documentation.

Returns an array or array ref (based on wantarray) of CatalystX::CRUD::Object::RDBO objects.

count( @params )

@params is passed directly to the Manager get_objects_count() method. See the Rose::DB::Object::Manager documentation.

Returns an integer.

iterator( @params )

@params is passed directly to the Manager get_objects_iterator() method. See the Rose::DB::Object::Manager documentation.

Returns a CatalystX::CRUD::Iterator object whose next() method will return a CatalystX::CRUD::Object::RDBO object.

has_relationship( obj, rel_name )

Returns the Rose::DB::Object::Metadata::Relationship instance for rel_name if it exists, or undef if it does not.

make_query( field_names )

Implement a RDBO-specific query factory based on request parameters. Return value can be passed directly to search(), iterator() or count() as documented in the CatalystX::CRUD::Model API.

See CatalystX::CRUD::Model::Utils::make_sql_query() for API details.

treat_like_int

Returns hash ref of all column names that return type =~ m/^date(time)$/. This is so that wildcard searches for date and datetime-based columns will get proper SQL rendering.

AUTHOR

Top

Peter Karman, <karman at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-catalystx-crud-model-rdbo at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CatalystX-CRUD-Model-RDBO. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc CatalystX::CRUD::Model::RDBO

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/CatalystX-CRUD-Model-RDBO

* CPAN Ratings

http://cpanratings.perl.org/d/CatalystX-CRUD-Model-RDBO

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=CatalystX-CRUD-Model-RDBO

* Search CPAN

http://search.cpan.org/dist/CatalystX-CRUD-Model-RDBO

ACKNOWLEDGEMENTS

Top

This module is based on Catalyst::Model::RDBO by the same author.

COPYRIGHT & LICENSE

Top


CatalystX-CRUD-Model-RDBO documentation  | view source Contained in the CatalystX-CRUD-Model-RDBO distribution.