From: Norbert Buchmuller Date: Mon, 19 Jan 2009 04:19:31 +0000 (+0100) Subject: * Added documentation of "Arbitrary SQL through a custom ResultSource" alternate... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d00a5c68a046c661c3fe9991b8b6d4927c306ec6;p=dbsrgits%2FDBIx-Class-Historic.git * Added documentation of "Arbitrary SQL through a custom ResultSource" alternate method (ie. subclassing the resultset class and setting the custom resultsource on it) to the Cookbook. --- diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index dbc6a63..b86ab7a 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -151,7 +151,36 @@ Next, you can execute your complex query using bind parameters like this: } ) ]; -... and you'll get back a perfect L. +... and you'll get back a perfect L (except, of course, +that you cannot modify the rows it contains, ie. cannot call L, +L, ... on it). + +If you prefer to have the definitions of these custom ResultSources in separate +files (instead of stuffing all of them into the same resultset class), you can +achieve the same with subclassing the resultset class and defining the +ResultSource there: + + package My::Schema::UserFriendsComplex; + + use My::Schema::User; + use base qw/My::Schema::User/; + + __PACKAGE__->table('dummy'); # currently must be called before anything else + + # Hand in your query as a scalar reference + # It will be added as a sub-select after FROM, + # so pay attention to the surrounding brackets! + __PACKAGE__->name( \<