Option to disable the charging of the setup fee while a package is suspended.
[freeside.git] / install / 5.005 / DBIx-DBSchema-0.23-5.005kludge / DBSchema / DBD.pm
1 package DBIx::DBSchema::DBD;
2
3 use strict;
4 use vars qw($VERSION);
5
6 $VERSION = '0.02';
7
8 =head1 NAME
9
10 DBIx::DBSchema::DBD - DBIx::DBSchema Driver Writer's Guide and Base Class
11
12 =head1 SYNOPSIS
13
14   perldoc DBIx::DBSchema::DBD
15
16   package DBIx::DBSchema::DBD::FooBase
17   use DBIx::DBSchmea::DBD;
18   @ISA = qw(DBIx::DBSchema::DBD);
19
20 =head1 DESCRIPTION
21
22 Drivers should be named DBIx::DBSchema::DBD::DatabaseName, where DatabaseName
23 is the same as the DBD:: driver for this database.  Drivers should implement the
24 following class methods:
25
26 =over 4
27
28 =item columns CLASS DBI_DBH TABLE
29
30 Given an active DBI database handle, return a listref of listrefs (see
31 L<perllol>), each containing six elements: column name, column type,
32 nullability, column length, column default, and a field reserved for
33 driver-specific use.
34
35 =item column CLASS DBI_DBH TABLE COLUMN
36
37 Same as B<columns> above, except return the listref for a single column.  You
38 can inherit from DBIx::DBSchema::DBD to provide this function.
39
40 =cut
41
42 sub column {
43   my($proto, $dbh, $table, $column) = @_;
44   #@a = grep { $_->[0] eq $column } @{ $proto->columns( $dbh, $table ) };
45   #$a[0];
46   @{ [
47     grep { $_->[0] eq $column } @{ $proto->columns( $dbh, $table ) }
48   ] }[0]; #force list context on grep, return scalar of first element
49 }
50
51 =item primary_key CLASS DBI_DBH TABLE
52
53 Given an active DBI database handle, return the primary key for the specified
54 table.
55
56 =item unique CLASS DBI_DBH TABLE
57
58 Given an active DBI database handle, return a hashref of unique indices.  The
59 keys of the hashref are index names, and the values are arrayrefs which point
60 a list of column names for each.  See L<perldsc/"HASHES OF LISTS"> and
61 L<DBIx::DBSchema::ColGroup>.
62
63 =item index CLASS DBI_DBH TABLE
64
65 Given an active DBI database handle, return a hashref of (non-unique) indices.
66 The keys of the hashref are index names, and the values are arrayrefs which
67 point a list of column names for each.  See L<perldsc/"HASHES OF LISTS"> and
68 L<DBIx::DBSchema::ColGroup>.
69
70 =back
71
72 =head1 TYPE MAPPING
73
74 You can define a %typemap array for your driver to map "standard" data    
75 types to database-specific types.  For example, the MySQL TIMESTAMP field
76 has non-standard auto-updating semantics; the MySQL DATETIME type is 
77 what other databases and the ODBC standard call TIMESTAMP, so one of the   
78 entries in the MySQL %typemap is:
79
80   'TIMESTAMP' => 'DATETIME',
81
82 Another example is the Pg %typemap which maps the standard types BLOB and
83 LONG VARBINARY to the Pg-specific BYTEA:
84
85   'BLOB' => 'BYTEA',
86   'LONG VARBINARY' => 'BYTEA',
87
88 Make sure you use all uppercase-keys.
89
90 =head1 AUTHOR
91
92 Ivan Kohler <ivan-dbix-dbschema@420.am>
93
94 =head1 COPYRIGHT
95
96 Copyright (c) 2000 Ivan Kohler
97 Copyright (c) 2000 Mail Abuse Prevention System LLC
98 All rights reserved.
99 This program is free software; you can redistribute it and/or modify it under
100 the same terms as Perl itself.
101
102 =head1 BUGS
103
104 =head1 SEE ALSO
105
106 L<DBIx::DBSchema>, L<DBIx::DBSchema::DBD::mysql>, L<DBIx::DBSchema::DBD::Pg>,
107 L<DBIx::DBSchema::ColGroup>, L<DBI>, L<DBI::DBD>, L<perllol>,
108 L<perldsc/"HASHES OF LISTS">
109
110 =cut 
111
112 1;
113