Thursday 8 April 2010

Retrieving the $schema object from the resultset object

More for my own personal reference

Within a resultset (row) object

my $schema = $self->result_source->schema();

Example reasoning

User wants to be able to obtain (via helper method) all the public groups s/he doesn't belong to

sub public_usergroups {
my ($self) = @_;

my $schema = $self->result_source->schema();

my @public_usergroups = $schema->resultset('Usergroup')->search({
id_usergroup => {
'NOT IN' => $self->user2usergroups->get_column('id_usergroup')->as_query,
},
is_public => 1,
});

return @public_usergroups;
}

The returned set are then also Usergroup objects, so they have the methods relating to those.

3 comments:

Joshua Smith said...

Thanks for your help in describing this. Great review! Also turn your attention that it needs to search for mobile software development companies if you need android applications development.

Joshua Smith said...

It's well done article. Let me mention about home insurance with discounts home insurance companies. Save on free online rates on homeowners insurance.

Joshua Smith said...

Thank you for posting this great info. You have affordable possibility to get info about casino affiliate. The most common casino programs such as go wild affiliate and great poker rooms such as red bet affiliates.