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.  Driv‐
19       ers 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 col‐
29           umn.  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
48           (non-unique) indices.  The keys of the hashref are index names, and
49           the values are arrayrefs which point a list of column names for
50           each.  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 com‐
75           mand.  Inheriting from DBIx::DBSchema::DBD will provide the default
76           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 defi‐
85           nitions.
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 cre‐
91           ation.
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 cre‐
100           ation.
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 cre‐
110           ation.
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_null - Alter SQL statment for changing nullability to be
126           used instead of the default
127

TYPE MAPPING

129       You can define a %typemap array for your driver to map "standard" data
130       types to database-specific types.  For example, the MySQL TIMESTAMP
131       field has non-standard auto-updating semantics; the MySQL DATETIME type
132       is what other databases and the ODBC standard call TIMESTAMP, so one of
133       the entries in the MySQL %typemap is:
134
135         'TIMESTAMP' => 'DATETIME',
136
137       Another example is the Pg %typemap which maps the standard types BLOB
138       and LONG VARBINARY to the Pg-specific BYTEA:
139
140         'BLOB' => 'BYTEA',
141         'LONG VARBINARY' => 'BYTEA',
142
143       Make sure you use all uppercase-keys.
144

AUTHOR

146       Ivan Kohler <ivan-dbix-dbschema@420.am>
147
149       Copyright (c) 2000-2005 Ivan Kohler Copyright (c) 2007 Freeside Inter‐
150       net Services, Inc.  All rights reserved.  This program is free soft‐
151       ware; you can redistribute it and/or modify it under the same terms as
152       Perl itself.
153

BUGS

SEE ALSO

156       DBIx::DBSchema, DBIx::DBSchema::DBD::mysql, DBIx::DBSchema::DBD::Pg,
157       DBIx::DBSchema::Index, DBI, DBI::DBD, perllol, "HASHES OF LISTS" in
158       perldsc
159
160
161
162perl v5.8.8                       2002-11-29                  DBSchema::DBD(3)
Impressum