1 package DBIx::DBSchema::DBD;
10 DBIx::DBSchema::DBD - DBIx::DBSchema Driver Writer's Guide and Base Class
14 perldoc DBIx::DBSchema::DBD
16 package DBIx::DBSchema::DBD::FooBase
17 use DBIx::DBSchmea::DBD;
18 @ISA = qw(DBIx::DBSchema::DBD);
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:
28 =item columns CLASS DBI_DBH TABLE
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
35 =item column CLASS DBI_DBH TABLE COLUMN
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.
43 my($proto, $dbh, $table, $column) = @_;
44 #@a = grep { $_->[0] eq $column } @{ $proto->columns( $dbh, $table ) };
47 grep { $_->[0] eq $column } @{ $proto->columns( $dbh, $table ) }
48 ] }[0]; #force list context on grep, return scalar of first element
51 =item primary_key CLASS DBI_DBH TABLE
53 Given an active DBI database handle, return the primary key for the specified
56 =item unique CLASS DBI_DBH TABLE
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>.
63 =item index CLASS DBI_DBH TABLE
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>.
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:
80 'TIMESTAMP' => 'DATETIME',
82 Another example is the Pg %typemap which maps the standard types BLOB and
83 LONG VARBINARY to the Pg-specific BYTEA:
86 'LONG VARBINARY' => 'BYTEA',
88 Make sure you use all uppercase-keys.
92 Ivan Kohler <ivan-dbix-dbschema@420.am>
96 Copyright (c) 2000 Ivan Kohler
97 Copyright (c) 2000 Mail Abuse Prevention System LLC
99 This program is free software; you can redistribute it and/or modify it under
100 the same terms as Perl itself.
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">