1DBSchema::DBD(3)      User Contributed Perl Documentation     DBSchema::DBD(3)
2
3
4

NAME

6       DBIx::DBSchema::DBD - DBIx::DBSchema Driver Writer's Guide and Base
7       Class
8

SYNOPSIS

10         perldoc DBIx::DBSchema::DBD
11
12         package DBIx::DBSchema::DBD::FooBase
13         use DBIx::DBSchema::DBD;
14         @ISA = qw(DBIx::DBSchema::DBD);
15

DESCRIPTION

17       Drivers should be named DBIx::DBSchema::DBD::DatabaseName, where
18       DatabaseName is the same as the DBD:: driver for this database.
19       Drivers should implement the following class methods:
20
21       columns CLASS DBI_DBH TABLE
22           Given an active DBI database handle, return a listref of listrefs
23           (see perllol), each containing six elements: column name, column
24           type, nullability, column length, column default, and a field
25           reserved for driver-specific use.
26
27       column CLASS DBI_DBH TABLE COLUMN
28           Same as columns above, except return the listref for a single
29           column.  You can inherit from DBIx::DBSchema::DBD to provide this
30           function.
31
32       primary_key CLASS DBI_DBH TABLE
33           Given an active DBI database handle, return the primary key for the
34           specified table.
35
36       unique CLASS DBI_DBH TABLE
37           Deprecated method - see the indices method for new drivers.
38
39           Given an active DBI database handle, return a hashref of unique
40           indices.  The keys of the hashref are index names, and the values
41           are arrayrefs which point a list of column names for each.  See
42           "HASHES OF LISTS" in perldsc and DBIx::DBSchema::Index.
43
44       index CLASS DBI_DBH TABLE
45           Deprecated method - see the indices method for new drivers.
46
47           Given an active DBI database handle, return a hashref of (non-
48           unique) indices.  The keys of the hashref are index names, and the
49           values are arrayrefs which point a list of column names for each.
50           See "HASHES OF LISTS" in perldsc and DBIx::DBSchema::Index.
51
52       indices CLASS DBI_DBH TABLE
53           Given an active DBI database handle, return a hashref of all
54           indices, both unique and non-unique.  The keys of the hashref are
55           index names, and the values are again hashrefs with the following
56           keys:
57
58           name - Index name (redundant)
59           using - Optional index method
60           unique - Boolean indicating whether or not this is a unique index
61           columns - List reference of column names (or expressions)
62
63           (See FS::DBIx::DBSchema::Index)
64
65           New drivers are advised to implement this method, and existing
66           drivers are advised to (eventually) provide this method instead of
67           index and unique.
68
69           For backwards-compatibility with current drivers, the base
70           DBIx::DBSchema::DBD class provides an indices method which uses the
71           old index and unique methods to provide this data.
72
73       default_db_catalog
74           Returns the default database catalog for the DBI table_info
75           command.  Inheriting from DBIx::DBSchema::DBD will provide the
76           default empty string.
77
78       default_db_schema
79           Returns the default database schema for the DBI table_info command.
80           Inheriting from DBIx::DBSchema::DBD will provide the default empty
81           string.
82
83       column_callback DBH TABLE_NAME COLUMN_OBJ
84           Optional callback for driver-specific overrides to SQL column
85           definitions.
86
87           Should return a hash reference, empty for no action, or with one or
88           more of the following keys defined:
89
90           effective_type - Optional type override used during column
91           creation.
92
93           explicit_null - Set true to have the column definition declare NULL
94           columns explicitly
95
96           effective_default - Optional default override used during column
97           creation.
98
99           effective_local - Optional local override used during column
100           creation.
101
102       add_column_callback DBH TABLE_NAME COLUMN_OBJ
103           Optional callback for additional SQL statments to be called when
104           adding columns to an existing table.
105
106           Should return a hash reference, empty for no action, or with one or
107           more of the following keys defined:
108
109           effective_type - Optional type override used during column
110           creation.
111
112           effective_null - Optional nullability override used during column
113           creation.
114
115           sql_after - Array reference of SQL statements to be executed after
116           the column is added.
117
118       alter_column_callback DBH TABLE_NAME OLD_COLUMN_OBJ NEW_COLUMN_OBJ
119           Optional callback for overriding the SQL statments to be called
120           when altering columns to an existing table.
121
122           Should return a hash reference, empty for no action, or with one or
123           more of the following keys defined:
124
125           sql_alter - Alter SQL statement(s) for changing everything about a
126           column.  Specifying this overrides processing of individual changes
127           (type, nullability, default, etc.).
128
129           sql_alter_type - Alter SQL statement(s) for changing type and
130           length (there is no default).
131
132           sql_alter_null - Alter SQL statement(s) for changing nullability to
133           be used instead of the default.
134
135       column_value_needs_quoting COLUMN_OBJ
136           Optional callback for determining if a column's default value
137           require quoting.  Returns true if it does, false otherwise.
138

TYPE MAPPING

140       You can define a %typemap array for your driver to map "standard" data
141       types to database-specific types.  For example, the MySQL TIMESTAMP
142       field has non-standard auto-updating semantics; the MySQL DATETIME type
143       is what other databases and the ODBC standard call TIMESTAMP, so one of
144       the entries in the MySQL %typemap is:
145
146         'TIMESTAMP' => 'DATETIME',
147
148       Another example is the Pg %typemap which maps the standard types BLOB
149       and LONG VARBINARY to the Pg-specific BYTEA:
150
151         'BLOB' => 'BYTEA',
152         'LONG VARBINARY' => 'BYTEA',
153
154       Make sure you use all uppercase-keys.
155

AUTHOR

157       Ivan Kohler <ivan-dbix-dbschema@420.am>
158
160       Copyright (c) 2000-2005 Ivan Kohler Copyright (c) 2007-2010 Freeside
161       Internet Services, Inc.  All rights reserved.  This program is free
162       software; you can redistribute it and/or modify it under the same terms
163       as Perl itself.
164

BUGS

SEE ALSO

167       DBIx::DBSchema, DBIx::DBSchema::DBD::mysql, DBIx::DBSchema::DBD::Pg,
168       DBIx::DBSchema::Index, DBI, DBI::DBD, perllol, "HASHES OF LISTS" in
169       perldsc
170
171
172
173perl v5.12.1                      2010-01-09                  DBSchema::DBD(3)
Impressum