added datetime parser for MSSQL (ta LTJake)
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / MSSQL.pm
1 package DBIx::Class::Storage::DBI::MSSQL;
2 \r
3 use strict;
4 use warnings;
5 \r
6 use base qw/DBIx::Class::Storage::DBI/;
7 \r
8 # __PACKAGE__->load_components(qw/PK::Auto/);
9 \r
10 sub last_insert_id {
11   my( $id ) = $_[0]->_dbh->selectrow_array('SELECT @@IDENTITY' );
12   return $id;
13 }
14
15 sub build_datetime_parser {
16   my $self = shift;
17   my $type = "DateTime::Format::Strptime";
18   eval "use ${type}";
19   $self->throw_exception("Couldn't load ${type}: $@") if $@;
20   return $type->new( pattern => '%m/%d/%Y %H:%M:%S' );
21 }
22 \r
23 1;
24 \r
25 =head1 NAME
26 \r
27 DBIx::Class::Storage::DBI::MSSQL - Automatic primary key class for MSSQL
28 \r
29 =head1 SYNOPSIS
30 \r
31   # In your table classes
32   __PACKAGE__->load_components(qw/PK::Auto Core/);
33   __PACKAGE__->set_primary_key('id');
34 \r
35 =head1 DESCRIPTION
36 \r
37 This class implements autoincrements for MSSQL.
38 \r
39 =head1 AUTHORS
40 \r
41 Brian Cassidy <bricas@cpan.org>
42 \r
43 =head1 LICENSE
44 \r
45 You may distribute this code under the same terms as Perl itself.
46 \r
47 =cut