1 package DBIx::DBSchema::DBD::mysql;
4 use vars qw($VERSION @ISA %typemap);
5 use DBIx::DBSchema::DBD;
8 @ISA = qw(DBIx::DBSchema::DBD);
11 'TIMESTAMP' => 'DATETIME',
12 'SERIAL' => 'INTEGER',
14 'LONG VARBINARY' => 'LONGBLOB',
19 DBIx::DBSchema::DBD::mysql - MySQL native driver for DBIx::DBSchema
26 $dbh = DBI->connect('dbi:mysql:database', 'user', 'pass');
27 $schema = new_native DBIx::DBSchema $dbh;
31 This module implements a MySQL-native driver for DBIx::DBSchema.
36 my($proto, $dbh, $table ) = @_;
37 my $sth = $dbh->prepare("SHOW COLUMNS FROM $table") or die $dbh->errstr;
38 $sth->execute or die $sth->errstr;
40 $_->{'Type'} =~ /^(\w+)\(?([\d\,]+)?\)?( unsigned)?$/
41 or die "Illegal type: ". $_->{'Type'}. "\n";
42 my($type, $length) = ($1, $2);
51 } @{ $sth->fetchall_arrayref( {} ) };
55 # my($proto, $dbh, $table ) = @_;
56 # my $primary_key = '';
57 # my $sth = $dbh->prepare("SHOW INDEX FROM $table")
58 # or die $dbh->errstr;
59 # $sth->execute or die $sth->errstr;
60 # my @pkey = map { $_->{'Column_name'} } grep {
61 # $_->{'Key_name'} eq "PRIMARY"
62 # } @{ $sth->fetchall_arrayref( {} ) };
63 # scalar(@pkey) ? $pkey[0] : '';
67 my($proto, $dbh, $table) = @_;
68 my($pkey, $unique_href, $index_href) = $proto->_show_index($dbh, $table);
73 my($proto, $dbh, $table) = @_;
74 my($pkey, $unique_href, $index_href) = $proto->_show_index($dbh, $table);
79 my($proto, $dbh, $table) = @_;
80 my($pkey, $unique_href, $index_href) = $proto->_show_index($dbh, $table);
85 my($proto, $dbh, $table ) = @_;
86 my $sth = $dbh->prepare("SHOW INDEX FROM $table")
88 $sth->execute or die $sth->errstr;
92 foreach my $row ( @{ $sth->fetchall_arrayref({}) } ) {
93 if ( $row->{'Key_name'} eq 'PRIMARY' ) {
94 $pkey = $row->{'Column_name'};
95 } elsif ( $row->{'Non_unique'} ) { #index
96 push @{ $index{ $row->{'Key_name'} } }, $row->{'Column_name'};
98 push @{ $unique{ $row->{'Key_name'} } }, $row->{'Column_name'};
102 ( $pkey, \%unique, \%index );
107 Ivan Kohler <ivan-dbix-dbschema@420.am>
111 Copyright (c) 2000 Ivan Kohler
112 Copyright (c) 2000 Mail Abuse Prevention System LLC
114 This program is free software; you can redistribute it and/or modify it under
115 the same terms as Perl itself.
121 L<DBIx::DBSchema>, L<DBIx::DBSchema::DBD>, L<DBI>, L<DBI::DBD>