X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FManual%2FCookbook.pod;h=b86ab7a334b4e535379d7cb5743a39f4c5933ec0;hb=d00a5c68a046c661c3fe9991b8b6d4927c306ec6;hp=9a642f9b264aa4cd1c49dba04536a99bc066ebb7;hpb=c4d239930f5d96be7ddccdb59ff07ff1bd43698d;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 9a642f9..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( \< needs to be set to allow the SQL generator to put the quotes the correct place. In most cases you should set these as part of the arguments passed to -L: +L: my $schema = My::Schema->connect( 'dbi:mysql:my_db',