[Dbix-class] Re: want to confirm on issue in cookbook
Mike.G
hylinux at gmail.com
Mon Nov 10 02:51:26 GMT 2008
about this statement:
$new_source->name( \<<SQL );
why I can't find out the method name "name" in class ResultSource?
thanks
Mike.G
2008/11/9 Mike. G <hylinux at gmail.com>
> Hi, everyone, I think I had asked this problem, but I forgot this.
> please remind me. thanks
>
> in cookbook, we have example like this:
>
> package My::Schema::User;
>
> use base qw/DBIx::Class/;
>
>
> # ->load_components, ->table, ->add_columns, etc.
>
> # Make a new ResultSource based on the User class
> my $source =3D __PACKAGE__->result_source_instance();
> my $new_source =3D $source->new( $source );
>
> $new_source->source_name( 'UserFriendsComplex' );
>
> # 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!
>
> $new_source->name( \<<SQL );
> ( SELECT u.* FROM user u
> INNER JOIN user_friends f ON u.id =3D f.user_id
> WHERE f.friend_user_id =3D ?
> UNION
> SELECT u.* FROM user u
>
> INNER JOIN user_friends f ON u.id =3D f.friend_user_id
> WHERE f.user_id =3D ? )
> SQL
>
> # Finally, register your new ResultSource with your Schema
>
>
>
> I think this is register myself ResultSource,
>
> but I have those question:
> 1.
> my $source =3D __PACKAGE__->result_source_instance();
> the method result_source_instance is which class's method?
>
> 2. I had take a look the ResultSource method:
> I found there are no any method like :
>
> my $new_source =3D $source->new( $source );
> so, that document's issue?
>
>
> thanks
>
> Mike.G
>
>
> My::Schema->register_source( 'UserFriendsComplex' =3D> $new_source );
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20081110/9d2=
17451/attachment.htm
More information about the DBIx-Class
mailing list