| CatalystX-CRUD-Model-RDBO documentation | view source | Contained in the CatalystX-CRUD-Model-RDBO distribution. |
CatalystX::CRUD::Model::RDBO - Rose::DB::Object CRUD
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;
CatalystX::CRUD::Model::RDBO is a CatalystX::CRUD implementation for Rose::DB::Object.
The config options can be set as in the SYNOPSIS example.
The name of the Rose::DB::Object-based class that the model represents. Accessible via name() or config->{name}.
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.
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.
Implements the required Xsetup() method. Instatiates the model's name() and manager() values based on config().
Returns a CatalystX::CRUD::Object::RDBO object.
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
}
@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.
@params is passed directly to the Manager get_objects_count() method. See the Rose::DB::Object::Manager documentation.
Returns an integer.
@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.
Returns the Rose::DB::Object::Metadata::Relationship instance for rel_name if it exists, or undef if it does not.
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.
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.
Peter Karman, <karman at cpan.org>
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.
You can find documentation for this module with the perldoc command.
perldoc CatalystX::CRUD::Model::RDBO
You can also look for information at:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=CatalystX-CRUD-Model-RDBO
This module is based on Catalyst::Model::RDBO by the same author.
Copyright 2007 Peter Karman, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| CatalystX-CRUD-Model-RDBO documentation | view source | Contained in the CatalystX-CRUD-Model-RDBO distribution. |