• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

inc/Module/H14-Jun-2009-2,5271,874

lib/DBIx/Class/ResultSet/H14-Jun-2009-15129

t/H14-Jun-2009-464422

ChangesH A D14-Jun-2009345 149

MANIFESTH A D14-Jun-2009572 2625

META.ymlH A D14-Jun-2009575 2726

Makefile.PLH A D03-May-2022325 1810

READMEH A D14-Jun-20092.5 KiB9367

README

1NAME
2    DBIx::Class::ResultSet::HashRef - Adds syntactic sugar to skip the fancy
3    objects
4
5SYNOPSIS
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
21DESCRIPTION
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
25INSTALLATION
26        perl Makefile.PL
27        make
28        make test
29        make install
30
31METHODS
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
53  hashref_pk( )
54    Returns a hash or reference to hash, depending on the calling context.
55    The keys of the hash are the primary keys of each row returned by
56    "hashref_array( )":
57
58            {
59                    1 => {
60                        'id'    => '1',
61                        'login' => 'root'
62                    },
63                    2 => {
64                        'id'    => '2',
65                        'login' => 'toor'
66                    },
67            }
68
69    Example usage:
70
71        my $hashref_pk = $schema->resultset('User')->search( { } )->hashref_pk;
72        print Dumper $hashref_pk
73
74AUTHOR
75    Johannes Plunien <plu@cpan.org>
76
77CONTRIBUTORS
78    Robert Bohne <rbo@cpan.org>
79
80COPYRIGHT AND LICENSE
81    Copyright 2008 by Johannes Plunien
82
83    This library is free software; you can redistribute it and/or modify it
84    under the same terms as Perl itself.
85
86    Thanks to mst for his patience.
87
88SEE ALSO
89    *   DBIx::Class
90
91    *   DBIx::Class::ResultClass::HashRefInflator
92
93