File | /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class.pm | Statements Executed | 81 | Total Time | 0.001582 seconds |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine | |
---|---|---|---|---|---|---|
14 | 1 | 1 | 0.00023 | 0.00249 | DBIx::Class:: | mk_classaccessor |
14 | 10 | 2 | 0.00020 | 0.00269 | DBIx::Class:: | mk_classdata |
8 | 1 | 1 | 4.3e-5 | 4.3e-5 | DBIx::Class:: | component_base_class |
0 | 0 | 0 | 0 | 0 | DBIx::Class:: | BEGIN |
0 | 0 | 0 | 0 | 0 | DBIx::Class:: | MODIFY_CODE_ATTRIBUTES |
0 | 0 | 0 | 0 | 0 | DBIx::Class:: | _attr_cache |
Line | Stmts. | Exclusive Time | Avg. | Code |
---|---|---|---|---|
1 | package DBIx::Class; | |||
2 | ||||
3 | 3 | 2.7e-5 | 9.0e-6 | use strict; # spent 9µs making 1 call to strict::import |
4 | 3 | 2.8e-5 | 9.3e-6 | use warnings; # spent 24µs making 1 call to warnings::import |
5 | ||||
6 | 3 | 3.2e-5 | 1.1e-5 | use vars qw($VERSION); # spent 25µs making 1 call to vars::import |
7 | 3 | 4.7e-5 | 1.6e-5 | use base qw/DBIx::Class::Componentised Class::Accessor::Grouped/; # spent 17.3ms making 1 call to base::import, max recursion depth 2 |
8 | 3 | 0.00097 | 0.00032 | use DBIx::Class::StartupCheck; # spent 3µs making 1 call to import |
9 | ||||
10 | ||||
11 | # spent 2.69ms (204µs+2.49) within DBIx::Class::mk_classdata which was called 14 times, avg 192µs/call:
# 5 times (122µs+1.07ms) by DBIx::Class::ResultSourceProxy::Table::table at line 57 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/ResultSourceProxy/Table.pm, avg 239µs/call
# once (13µs+269µs) at line 14 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Schema.pm
# once (16µs+180µs) at line 10 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/ResultSourceProxy/Table.pm
# once (7µs+149µs) at line 20 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Schema.pm
# once (7µs+147µs) at line 15 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Schema.pm
# once (8µs+144µs) at line 16 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Schema.pm
# once (8µs+143µs) at line 19 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Schema.pm
# once (8µs+132µs) at line 17 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Schema.pm
# once (8µs+130µs) at line 12 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/ResultSourceProxy/Table.pm
# once (7µs+123µs) at line 18 of /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/Schema.pm | |||
12 | 14 | 0.00017 | 1.2e-5 | shift->mk_classaccessor(@_); # spent 2.49ms making 14 calls to DBIx::Class::mk_classaccessor, avg 178µs/call |
13 | } | |||
14 | ||||
15 | # spent 2.49ms (232µs+2.26) within DBIx::Class::mk_classaccessor which was called 14 times, avg 178µs/call:
# 14 times (232µs+2.26ms) by DBIx::Class::mk_classdata at line 12, avg 178µs/call | |||
16 | 42 | 0.00029 | 6.8e-6 | my $self = shift; |
17 | $self->mk_group_accessors('inherited', $_[0]); # spent 2.15ms making 14 calls to Class::Accessor::Grouped::mk_group_accessors, avg 154µs/call | |||
18 | $self->set_inherited(@_) if @_ > 1; # spent 105µs making 6 calls to Class::Accessor::Grouped::set_inherited, avg 18µs/call | |||
19 | } | |||
20 | ||||
21 | 8 | 1.7e-5 | 2.1e-6 | # spent 43µs within DBIx::Class::component_base_class which was called 8 times, avg 5µs/call:
# 8 times (43µs+0) by Class::C3::Componentised::load_components at line 61 of /wise/base/static/lib/perl5/site_perl/5.10.0/Class/C3/Componentised.pm, avg 5µs/call |
22 | ||||
23 | # Always remember to do all digits for the version even if they're 0 | |||
24 | # i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports | |||
25 | # brain damage and presumably various other packaging systems too | |||
26 | ||||
27 | 1 | 1.0e-6 | 1.0e-6 | $VERSION = '0.08009'; |
28 | ||||
29 | sub MODIFY_CODE_ATTRIBUTES { | |||
30 | my ($class,$code,@attrs) = @_; | |||
31 | $class->mk_classdata('__attr_cache' => {}) | |||
32 | unless $class->can('__attr_cache'); | |||
33 | $class->__attr_cache->{$code} = [@attrs]; | |||
34 | return (); | |||
35 | } | |||
36 | ||||
37 | sub _attr_cache { | |||
38 | my $self = shift; | |||
39 | my $cache = $self->can('__attr_cache') ? $self->__attr_cache : {}; | |||
40 | my $rest = eval { $self->next::method }; | |||
41 | return $@ ? $cache : { %$cache, %$rest }; | |||
42 | } | |||
43 | ||||
44 | 1 | 4.0e-6 | 4.0e-6 | 1; |
45 | ||||
46 | =head1 NAME | |||
47 | ||||
48 | DBIx::Class - Extensible and flexible object <-> relational mapper. | |||
49 | ||||
50 | =head1 SYNOPSIS | |||
51 | ||||
52 | Create a schema class called DB/Main.pm: | |||
53 | ||||
54 | package DB::Main; | |||
55 | use base qw/DBIx::Class::Schema/; | |||
56 | ||||
57 | __PACKAGE__->load_classes(); | |||
58 | ||||
59 | 1; | |||
60 | ||||
61 | Create a table class to represent artists, who have many CDs, in DB/Main/Artist.pm: | |||
62 | ||||
63 | package DB::Main::Artist; | |||
64 | use base qw/DBIx::Class/; | |||
65 | ||||
66 | __PACKAGE__->load_components(qw/PK::Auto Core/); | |||
67 | __PACKAGE__->table('artist'); | |||
68 | __PACKAGE__->add_columns(qw/ artistid name /); | |||
69 | __PACKAGE__->set_primary_key('artistid'); | |||
70 | __PACKAGE__->has_many(cds => 'DB::Main::CD'); | |||
71 | ||||
72 | 1; | |||
73 | ||||
74 | A table class to represent a CD, which belongs to an artist, in DB/Main/CD.pm: | |||
75 | ||||
76 | package DB::Main::CD; | |||
77 | use base qw/DBIx::Class/; | |||
78 | ||||
79 | __PACKAGE__->load_components(qw/PK::Auto Core/); | |||
80 | __PACKAGE__->table('cd'); | |||
81 | __PACKAGE__->add_columns(qw/ cdid artist title year /); | |||
82 | __PACKAGE__->set_primary_key('cdid'); | |||
83 | __PACKAGE__->belongs_to(artist => 'DB::Main::Artist'); | |||
84 | ||||
85 | 1; | |||
86 | ||||
87 | Then you can use these classes in your application's code: | |||
88 | ||||
89 | # Connect to your database. | |||
90 | use DB::Main; | |||
91 | my $schema = DB::Main->connect($dbi_dsn, $user, $pass, \%dbi_params); | |||
92 | ||||
93 | # Query for all artists and put them in an array, | |||
94 | # or retrieve them as a result set object. | |||
95 | my @all_artists = $schema->resultset('Artist')->all; | |||
96 | my $all_artists_rs = $schema->resultset('Artist'); | |||
97 | ||||
98 | # Create a result set to search for artists. | |||
99 | # This does not query the DB. | |||
100 | my $johns_rs = $schema->resultset('Artist')->search( | |||
101 | # Build your WHERE using an SQL::Abstract structure: | |||
102 | { name => { like => 'John%' } } | |||
103 | ); | |||
104 | ||||
105 | # Execute a joined query to get the cds. | |||
106 | my @all_john_cds = $johns_rs->search_related('cds')->all; | |||
107 | ||||
108 | # Fetch only the next row. | |||
109 | my $first_john = $johns_rs->next; | |||
110 | ||||
111 | # Specify ORDER BY on the query. | |||
112 | my $first_john_cds_by_title_rs = $first_john->cds( | |||
113 | undef, | |||
114 | { order_by => 'title' } | |||
115 | ); | |||
116 | ||||
117 | # Create a result set that will fetch the artist relationship | |||
118 | # at the same time as it fetches CDs, using only one query. | |||
119 | my $millennium_cds_rs = $schema->resultset('CD')->search( | |||
120 | { year => 2000 }, | |||
121 | { prefetch => 'artist' } | |||
122 | ); | |||
123 | ||||
124 | my $cd = $millennium_cds_rs->next; # SELECT ... FROM cds JOIN artists ... | |||
125 | my $cd_artist_name = $cd->artist->name; # Already has the data so no query | |||
126 | ||||
127 | # new() makes a DBIx::Class::Row object but doesnt insert it into the DB. | |||
128 | # create() is the same as new() then insert(). | |||
129 | my $new_cd = $schema->resultset('CD')->new({ title => 'Spoon' }); | |||
130 | $new_cd->artist($cd->artist); | |||
131 | $new_cd->insert; # Auto-increment primary key filled in after INSERT | |||
132 | $new_cd->title('Fork'); | |||
133 | ||||
134 | $schema->txn_do(sub { $new_cd->update }); # Runs the update in a transaction | |||
135 | ||||
136 | $millennium_cds_rs->update({ year => 2002 }); # Single-query bulk update | |||
137 | ||||
138 | =head1 DESCRIPTION | |||
139 | ||||
140 | This is an SQL to OO mapper with an object API inspired by L<Class::DBI> | |||
141 | (and a compatibility layer as a springboard for porting) and a resultset API | |||
142 | that allows abstract encapsulation of database operations. It aims to make | |||
143 | representing queries in your code as perl-ish as possible while still | |||
144 | providing access to as many of the capabilities of the database as possible, | |||
145 | including retrieving related records from multiple tables in a single query, | |||
146 | JOIN, LEFT JOIN, COUNT, DISTINCT, GROUP BY and HAVING support. | |||
147 | ||||
148 | DBIx::Class can handle multi-column primary and foreign keys, complex | |||
149 | queries and database-level paging, and does its best to only query the | |||
150 | database in order to return something you've directly asked for. If a | |||
151 | resultset is used as an iterator it only fetches rows off the statement | |||
152 | handle as requested in order to minimise memory usage. It has auto-increment | |||
153 | support for SQLite, MySQL, PostgreSQL, Oracle, SQL Server and DB2 and is | |||
154 | known to be used in production on at least the first four, and is fork- | |||
155 | and thread-safe out of the box (although your DBD may not be). | |||
156 | ||||
157 | This project is still under rapid development, so large new features may be | |||
158 | marked EXPERIMENTAL - such APIs are still usable but may have edge bugs. | |||
159 | Failing test cases are *always* welcome and point releases are put out rapidly | |||
160 | as bugs are found and fixed. | |||
161 | ||||
162 | We do our best to maintain full backwards compatibility for published | |||
163 | APIs, since DBIx::Class is used in production in many organisations, | |||
164 | and even backwards incompatible changes to non-published APIs will be fixed | |||
165 | if they're reported and doing so doesn't cost the codebase anything. | |||
166 | ||||
167 | The test suite is quite substantial, and several developer releases | |||
168 | are generally made to CPAN before the branch for the next release is | |||
169 | merged back to trunk for a major release. | |||
170 | ||||
171 | The community can be found via: | |||
172 | ||||
173 | Mailing list: http://lists.scsys.co.uk/mailman/listinfo/dbix-class/ | |||
174 | ||||
175 | SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ | |||
176 | ||||
177 | SVNWeb: http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/ | |||
178 | ||||
179 | IRC: irc.perl.org#dbix-class | |||
180 | ||||
181 | =head1 WHERE TO GO NEXT | |||
182 | ||||
183 | L<DBIx::Class::Manual::DocMap> lists each task you might want help on, and | |||
184 | the modules where you will find documentation. | |||
185 | ||||
186 | =head1 AUTHOR | |||
187 | ||||
188 | mst: Matt S. Trout <mst@shadowcatsystems.co.uk> | |||
189 | ||||
190 | (I mostly consider myself "project founder" these days but the AUTHOR heading | |||
191 | is traditional :) | |||
192 | ||||
193 | =head1 CONTRIBUTORS | |||
194 | ||||
195 | abraxxa: Alexander Hartmaier <alex_hartmaier@hotmail.com> | |||
196 | ||||
197 | aherzog: Adam Herzog <adam@herzogdesigns.com> | |||
198 | ||||
199 | andyg: Andy Grundman <andy@hybridized.org> | |||
200 | ||||
201 | ank: Andres Kievsky | |||
202 | ||||
203 | ash: Ash Berlin <ash@cpan.org> | |||
204 | ||||
205 | bert: Norbert Csongradi <bert@cpan.org> | |||
206 | ||||
207 | blblack: Brandon L. Black <blblack@gmail.com> | |||
208 | ||||
209 | bluefeet: Aran Deltac <bluefeet@cpan.org> | |||
210 | ||||
211 | captainL: Luke Saunders <luke.saunders@gmail.com> | |||
212 | ||||
213 | castaway: Jess Robinson | |||
214 | ||||
215 | claco: Christopher H. Laco | |||
216 | ||||
217 | clkao: CL Kao | |||
218 | ||||
219 | da5id: David Jack Olrik <djo@cpan.org> | |||
220 | ||||
221 | dkubb: Dan Kubb <dan.kubb-cpan@onautopilot.com> | |||
222 | ||||
223 | dnm: Justin Wheeler <jwheeler@datademons.com> | |||
224 | ||||
225 | draven: Marcus Ramberg <mramberg@cpan.org> | |||
226 | ||||
227 | dwc: Daniel Westermann-Clark <danieltwc@cpan.org> | |||
228 | ||||
229 | dyfrgi: Michael Leuchtenburg <michael@slashhome.org> | |||
230 | ||||
231 | gphat: Cory G Watson <gphat@cpan.org> | |||
232 | ||||
233 | jesper: Jesper Krogh | |||
234 | ||||
235 | jguenther: Justin Guenther <jguenther@cpan.org> | |||
236 | ||||
237 | jnapiorkowski: John Napiorkowski <jjn1056@yahoo.com> | |||
238 | ||||
239 | jon: Jon Schutz <jjschutz@cpan.org> | |||
240 | ||||
241 | jshirley: J. Shirley <jshirley@gmail.com> | |||
242 | ||||
243 | konobi: Scott McWhirter | |||
244 | ||||
245 | LTJake: Brian Cassidy <bricas@cpan.org> | |||
246 | ||||
247 | mattlaw: Matt Lawrence | |||
248 | ||||
249 | ned: Neil de Carteret | |||
250 | ||||
251 | nigel: Nigel Metheringham <nigelm@cpan.org> | |||
252 | ||||
253 | ningu: David Kamholz <dkamholz@cpan.org> | |||
254 | ||||
255 | Numa: Dan Sully <daniel@cpan.org> | |||
256 | ||||
257 | paulm: Paul Makepeace | |||
258 | ||||
259 | penguin: K J Cheetham | |||
260 | ||||
261 | perigrin: Chris Prather <chris@prather.org> | |||
262 | ||||
263 | phaylon: Robert Sedlacek <phaylon@dunkelheit.at> | |||
264 | ||||
265 | quicksilver: Jules Bean | |||
266 | ||||
267 | sc_: Just Another Perl Hacker | |||
268 | ||||
269 | scotty: Scotty Allen <scotty@scottyallen.com> | |||
270 | ||||
271 | semifor: Marc Mims <marc@questright.com> | |||
272 | ||||
273 | sszabo: Stephan Szabo <sszabo@bigpanda.com> | |||
274 | ||||
275 | Todd Lipcon | |||
276 | ||||
277 | Tom Hukins | |||
278 | ||||
279 | typester: Daisuke Murase <typester@cpan.org> | |||
280 | ||||
281 | victori: Victor Igumnov <victori@cpan.org> | |||
282 | ||||
283 | wdh: Will Hawes | |||
284 | ||||
285 | willert: Sebastian Willert <willert@cpan.org> | |||
286 | ||||
287 | zamolxes: Bogdan Lucaciu <bogdan@wiz.ro> | |||
288 | ||||
289 | =head1 LICENSE | |||
290 | ||||
291 | You may distribute this code under the same terms as Perl itself. | |||
292 | ||||
293 | =cut |