File | /wise/base/static/lib/perl5/site_perl/5.10.0/DBIx/Class/PK/Auto.pm | Statements Executed | 10 | Total Time | 0.000136 seconds |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine | |
---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | DBIx::Class::PK::Auto:: | BEGIN |
0 | 0 | 0 | 0 | 0 | DBIx::Class::PK::Auto:: | sequence |
Line | Stmts. | Exclusive Time | Avg. | Code |
---|---|---|---|---|
1 | package DBIx::Class::PK::Auto; | |||
2 | ||||
3 | #use base qw/DBIx::Class::PK/; | |||
4 | 3 | 3.2e-5 | 1.1e-5 | use base qw/DBIx::Class/; # spent 106µs making 1 call to base::import |
5 | 3 | 2.5e-5 | 8.3e-6 | use strict; # spent 9µs making 1 call to strict::import |
6 | 3 | 7.6e-5 | 2.5e-5 | use warnings; # spent 23µs making 1 call to warnings::import |
7 | ||||
8 | =head1 NAME | |||
9 | ||||
10 | DBIx::Class::PK::Auto - Automatic primary key class | |||
11 | ||||
12 | =head1 SYNOPSIS | |||
13 | ||||
14 | __PACKAGE__->load_components(qw/Core/); | |||
15 | __PACKAGE__->set_primary_key('id'); | |||
16 | ||||
17 | =head1 DESCRIPTION | |||
18 | ||||
19 | This class overrides the insert method to get automatically incremented primary | |||
20 | keys. | |||
21 | ||||
22 | __PACKAGE__->load_components(qw/Core/); | |||
23 | ||||
24 | PK::Auto is now part of Core. | |||
25 | ||||
26 | See L<DBIx::Class::Manual::Component> for details of component interactions. | |||
27 | ||||
28 | =head1 LOGIC | |||
29 | ||||
30 | C<PK::Auto> does this by letting the database assign the primary key field and | |||
31 | fetching the assigned value afterwards. | |||
32 | ||||
33 | =head1 METHODS | |||
34 | ||||
35 | =head2 insert | |||
36 | ||||
37 | The code that was handled here is now in Row for efficiency. | |||
38 | ||||
39 | =head2 sequence | |||
40 | ||||
41 | Manually define the correct sequence for your table, to avoid the overhead | |||
42 | associated with looking up the sequence automatically. | |||
43 | ||||
44 | =cut | |||
45 | ||||
46 | sub sequence { | |||
47 | my ($self,$seq) = @_; | |||
48 | foreach my $pri ($self->primary_columns) { | |||
49 | $self->column_info($pri)->{sequence} = $seq; | |||
50 | } | |||
51 | } | |||
52 | ||||
53 | 1 | 3.0e-6 | 3.0e-6 | 1; |
54 | ||||
55 | =head1 AUTHORS | |||
56 | ||||
57 | Matt S. Trout <mst@shadowcatsystems.co.uk> | |||
58 | ||||
59 | =head1 LICENSE | |||
60 | ||||
61 | You may distribute this code under the same terms as Perl itself. | |||
62 | ||||
63 | =cut |