← Index
Performance Profile   « block view • line view • sub view »
For /wise/base/deliv/dev/bin/getfix
  Run on Thu May 20 15:30:03 2010
Reported on Thu May 20 16:25:35 2010

File/wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class.pm
Statements Executed81
Total Time0.001582 seconds

Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
14110.000230.00249DBIx::Class::mk_classaccessor
141020.000200.00269DBIx::Class::mk_classdata
8114.3e-54.3e-5DBIx::Class::component_base_class
00000DBIx::Class::BEGIN
00000DBIx::Class::MODIFY_CODE_ATTRIBUTES
00000DBIx::Class::_attr_cache

LineStmts.Exclusive
Time
Avg.Code
1package DBIx::Class;
2
332.7e-59.0e-6use strict;
# spent 9µs making 1 call to strict::import
432.8e-59.3e-6use warnings;
# spent 24µs making 1 call to warnings::import
5
633.2e-51.1e-5use vars qw($VERSION);
# spent 25µs making 1 call to vars::import
734.7e-51.6e-5use base qw/DBIx::Class::Componentised Class::Accessor::Grouped/;
# spent 17.3ms making 1 call to base::import, max recursion depth 2
830.000970.00032use DBIx::Class::StartupCheck;
# spent 3µs making 1 call to import
9
10
11sub mk_classdata {
12140.000171.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
sub mk_classaccessor {
16420.000296.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
2181.7e-52.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
sub component_base_class { 'DBIx::Class' }
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
2711.0e-61.0e-6$VERSION = '0.08009';
28
29sub 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
37sub _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
4414.0e-64.0e-61;
45
46=head1 NAME
47
48DBIx::Class - Extensible and flexible object <-> relational mapper.
49
50=head1 SYNOPSIS
51
52Create 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
61Create 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
74A 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
87Then 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
140This 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
142that allows abstract encapsulation of database operations. It aims to make
143representing queries in your code as perl-ish as possible while still
144providing access to as many of the capabilities of the database as possible,
145including retrieving related records from multiple tables in a single query,
146JOIN, LEFT JOIN, COUNT, DISTINCT, GROUP BY and HAVING support.
147
148DBIx::Class can handle multi-column primary and foreign keys, complex
149queries and database-level paging, and does its best to only query the
150database in order to return something you've directly asked for. If a
151resultset is used as an iterator it only fetches rows off the statement
152handle as requested in order to minimise memory usage. It has auto-increment
153support for SQLite, MySQL, PostgreSQL, Oracle, SQL Server and DB2 and is
154known to be used in production on at least the first four, and is fork-
155and thread-safe out of the box (although your DBD may not be).
156
157This project is still under rapid development, so large new features may be
158marked EXPERIMENTAL - such APIs are still usable but may have edge bugs.
159Failing test cases are *always* welcome and point releases are put out rapidly
160as bugs are found and fixed.
161
162We do our best to maintain full backwards compatibility for published
163APIs, since DBIx::Class is used in production in many organisations,
164and even backwards incompatible changes to non-published APIs will be fixed
165if they're reported and doing so doesn't cost the codebase anything.
166
167The test suite is quite substantial, and several developer releases
168are generally made to CPAN before the branch for the next release is
169merged back to trunk for a major release.
170
171The 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
183L<DBIx::Class::Manual::DocMap> lists each task you might want help on, and
184the modules where you will find documentation.
185
186=head1 AUTHOR
187
188mst: Matt S. Trout <mst@shadowcatsystems.co.uk>
189
190(I mostly consider myself "project founder" these days but the AUTHOR heading
191is traditional :)
192
193=head1 CONTRIBUTORS
194
195abraxxa: Alexander Hartmaier <alex_hartmaier@hotmail.com>
196
197aherzog: Adam Herzog <adam@herzogdesigns.com>
198
199andyg: Andy Grundman <andy@hybridized.org>
200
201ank: Andres Kievsky
202
203ash: Ash Berlin <ash@cpan.org>
204
205bert: Norbert Csongradi <bert@cpan.org>
206
207blblack: Brandon L. Black <blblack@gmail.com>
208
209bluefeet: Aran Deltac <bluefeet@cpan.org>
210
211captainL: Luke Saunders <luke.saunders@gmail.com>
212
213castaway: Jess Robinson
214
215claco: Christopher H. Laco
216
217clkao: CL Kao
218
219da5id: David Jack Olrik <djo@cpan.org>
220
221dkubb: Dan Kubb <dan.kubb-cpan@onautopilot.com>
222
223dnm: Justin Wheeler <jwheeler@datademons.com>
224
225draven: Marcus Ramberg <mramberg@cpan.org>
226
227dwc: Daniel Westermann-Clark <danieltwc@cpan.org>
228
229dyfrgi: Michael Leuchtenburg <michael@slashhome.org>
230
231gphat: Cory G Watson <gphat@cpan.org>
232
233jesper: Jesper Krogh
234
235jguenther: Justin Guenther <jguenther@cpan.org>
236
237jnapiorkowski: John Napiorkowski <jjn1056@yahoo.com>
238
239jon: Jon Schutz <jjschutz@cpan.org>
240
241jshirley: J. Shirley <jshirley@gmail.com>
242
243konobi: Scott McWhirter
244
245LTJake: Brian Cassidy <bricas@cpan.org>
246
247mattlaw: Matt Lawrence
248
249ned: Neil de Carteret
250
251nigel: Nigel Metheringham <nigelm@cpan.org>
252
253ningu: David Kamholz <dkamholz@cpan.org>
254
255Numa: Dan Sully <daniel@cpan.org>
256
257paulm: Paul Makepeace
258
259penguin: K J Cheetham
260
261perigrin: Chris Prather <chris@prather.org>
262
263phaylon: Robert Sedlacek <phaylon@dunkelheit.at>
264
265quicksilver: Jules Bean
266
267sc_: Just Another Perl Hacker
268
269scotty: Scotty Allen <scotty@scottyallen.com>
270
271semifor: Marc Mims <marc@questright.com>
272
273sszabo: Stephan Szabo <sszabo@bigpanda.com>
274
275Todd Lipcon
276
277Tom Hukins
278
279typester: Daisuke Murase <typester@cpan.org>
280
281victori: Victor Igumnov <victori@cpan.org>
282
283wdh: Will Hawes
284
285willert: Sebastian Willert <willert@cpan.org>
286
287zamolxes: Bogdan Lucaciu <bogdan@wiz.ro>
288
289=head1 LICENSE
290
291You may distribute this code under the same terms as Perl itself.
292
293=cut