1DateTime::Format::DBI(3U)ser Contributed Perl DocumentatiDoanteTime::Format::DBI(3)
2
3
4

NAME

6       DateTime::Format::DBI - Find a parser class for a database connection.
7

SYNOPSIS

9         use DBI;
10         use DateTime;
11         use DateTime::Format::DBI;
12
13         my $db = DBI->connect('dbi:...');
14         my $db_parser = DateTime::Format::DBI->new($dbh);
15         my $dt = DateTime->now();
16
17         $db->do("UPDATE table SET dt=? WHERE foo='bar'",undef,
18           $db_parser->format_datetime($dt);
19

DESCRIPTION

21       This module finds a "DateTime::Format::*" class that is suitable for
22       the use with a given DBI connection (and "DBD::*" driver).
23
24       It currently supports the following drivers: IBM DB2 (DB2), MySQL, #
25       Oracle, PostgreSQL (Pg).
26
27       WARNING: This module provides a quick method to find the correct
28       parser/formatter class. However, this is usually not enough for full
29       database abstraction. You will usually have to care for differences not
30       only in datetime syntax but also in the syntax and semantics of SQL
31       datetime functions (and other SQL commands).
32

CLASS METHODS

34       ·   new( $dbh )
35
36           Creates a new "DateTime::Format::*" instance the exact class of
37           which depends on the driver used for the database connection
38           referenced by $dbh.
39

PARSER/FORMATTER INTERFACE

41       "DateTime::Format::DBI" is just a front-end factory that will return
42       one of the format classes based on the nature of your $dbh.
43
44       For information on the interface of the returned parser object, please
45       see the documentation for the class pertaining to your particular $dbh.
46
47       In general, parser classes for databases will implement the following
48       methods.  For more information on the exact behaviour of these methods,
49       see the documentation of the parser class.
50
51       ·   parse_datetime( $string )
52
53           Given a string containing a date and/or time representation from
54           the database used, this method will return a new "DateTime" object.
55
56           If given an improperly formatted string, this method may die.
57
58       ·   format_datetime( $dt )
59
60           Given a "DateTime" object, this method returns a string appropriate
61           as input for all or the most common date and date/time types of the
62           database used.
63
64       ·   parse_duration( $string )
65
66           Given a string containing a duration representation from the
67           database used, this method will return a new "DateTime::Duration"
68           object.
69
70           If given an improperly formatted string, this method may die.
71
72           Not all databases and format/formatter classes support durations;
73           please use UNIVERSAL::has to check for the availability of this
74           method.
75
76       ·   format_duration( $du )
77
78           Given a "DateTime::Duration" object, this method returns a string
79           appropriate as input for the duration or interval type of the
80           database used.
81
82           Not all databases and parser/formatter classes support durations;
83           please use UNIVERSAL::has to check for the availability of this
84           method.
85
86       Parser/formatter classes may additionally define methods like
87       parse_type or format_type (where type is derived from the SQL type);
88       please see the documentation of the individual format class for more
89       information.
90

SUPPORT

92       Support for this module is provided via the datetime@perl.org email
93       list.  See http://lists.perl.org/ for more details.
94

AUTHOR

96       Claus A. FA~XAXrber <perl@cfaerber.name>
97
99       Copyright A~XAX 2003-2008 Claus A. FA~XAXrber.  All rights reserved.
100
101       This program is free software; you can redistribute it and/or modify it
102       under the same terms as Perl itself.
103
104       The full text of the license can be found in the LICENSE file included
105       with this module.
106

SEE ALSO

108       DateTime, DBI
109
110       datetime@perl.org mailing list
111
112       http://datetime.perl.org/
113
114
115
116perl v5.12.0                      2010-04-30          DateTime::Format::DBI(3)
Impressum