Commit | Line | Data |
8d028daa |
1 | NAME |
278f527b |
2 | DBIx::Class::ResultSet::HashRef - Adds syntactic sugar to skip the fancy |
8d028daa |
3 | objects |
4 | |
5 | SYNOPSIS |
6 | # in your resultsource class |
7 | __PACKAGE__->resultset_class( 'DBIx::Class::ResultSet::HashRef' ); |
8 | |
9 | # in your calling code |
10 | my $rs = $schema->resultset('User')->search( { } )->hashref_rs; |
11 | while (my $row = $rs->next) { |
12 | print Dumper $row; |
13 | } |
14 | |
15 | You can chain up every L<DBIx::Class::ResultSet> method to ->hashref_rs: |
16 | |
17 | * ->hashref_rs->all (same as ->hashref_array) |
18 | |
19 | * ->hashref_rs->first (same as ->hashref_first) |
20 | |
21 | DESCRIPTION |
22 | This is a simple way to allow you to set result_class to |
23 | DBIx::Class::ResultClass::HashRefInflator to skip the fancy objects. |
24 | |
25 | INSTALLATION |
26 | perl Makefile.PL |
27 | make |
28 | make test |
29 | make install |
30 | |
31 | METHODS |
32 | hashref_rs( ) |
33 | Sets result_class to DBIx::Class::ResultClass::HashRefInflator and |
34 | returns the resultset. |
35 | |
36 | hashref_array( ) |
37 | Calls ->hashref_rs->all and returns depending on the calling context an |
38 | array or an reference to an array. |
39 | |
40 | my $rs = $schema->resultset('User')->search( { } )->hashref_array; |
41 | print Dumper $rs; |
42 | |
43 | my @rs = $schema->resultset('User')->search( { } )->hashref_array; |
44 | print Dumper @rs; |
45 | |
46 | hashref_first( ) |
47 | Returns the first row of the resultset inflated by |
48 | DBIx::Class::ResultClass::HashRefInflator. |
49 | |
50 | my $first_row = $schema->resultset('User')->search( { } )->hashref_first; |
51 | print Dumper $first_row |
52 | |
698b98d0 |
53 | hashref_pk( ) |
54 | Calls hashref_array and returns a reference to a hash containing the |
55 | primary key. For each key the corresponding value is a reference to a |
56 | hash of the resultset inflated by |
57 | DBIx::Class::ResultClass::HashRefInflator. |
58 | |
59 | my $hashref_pk = $schema->resultset('User')->search( { } )->hashref_pk; |
60 | print Dumper $hashref_pk |
61 | |
8d028daa |
62 | AUTHOR |
63 | Johannes Plunien <plu@cpan.org> |
64 | |
c4d22621 |
65 | CONTRIBUTORS |
66 | Robert Bohne <rbo@cpan.org> |
67 | |
8d028daa |
68 | COPYRIGHT AND LICENSE |
69 | Copyright 2008 by Johannes Plunien |
70 | |
71 | This library is free software; you can redistribute it and/or modify it |
72 | under the same terms as Perl itself. |
73 | |
74 | Thanks to mst for his patience. |
75 | |
76 | SEE ALSO |
77 | * DBIx::Class |
78 | * DBIx::Class::ResultClass::HashRefInflator |
79 | |