From: Ash Berlin Date: Tue, 27 May 2008 12:49:09 +0000 (+0000) Subject: Add set_cache example to cookbook X-Git-Tag: v0.08240~447 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=204e5c03d9e5939cdd99198020d3650a16746505;p=dbsrgits%2FDBIx-Class.git Add set_cache example to cookbook --- diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 8fdd2d6..01b7fcf 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -763,6 +763,23 @@ This will cause the following SQL statement to be run: Which will of course only work if your database supports this function. See L for more documentation. +=head2 Creating a result set from a set of rows + +Sometimes you have a (set of) row objects that you want to put into a +resultset without the need to hit the DB again. You can do that by using the +L method: + + my @rows; + while (my $group = $groups->next) { + if ($group->can_upload($self)) { + push @uploadable_groups, $group; + } + } + my $new_rs = $self->result_source->resultset; + $new_rs->set_cache(\@uploadable_groups); + return $new_rs; + + =head1 USING RELATIONSHIPS =head2 Create a new row in a related table