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',
18 DBIx::DBSchema::DBD::mysql - MySQL native driver for DBIx::DBSchema
25 $dbh = DBI->connect('dbi:mysql:database', 'user', 'pass');
26 $schema = new_native DBIx::DBSchema $dbh;
30 This module implements a MySQL-native driver for DBIx::DBSchema.
35 my($proto, $dbh, $table ) = @_;
36 my $sth = $dbh->prepare("SHOW COLUMNS FROM $table") or die $dbh->errstr;
37 $sth->execute or die $sth->errstr;
39 $_->{'Type'} =~ /^(\w+)\(?([\d\,]+)?\)?( unsigned)?$/
40 or die "Illegal type: ". $_->{'Type'}. "\n";
41 my($type, $length) = ($1, $2);
50 } @{ $sth->fetchall_arrayref( {} ) };
54 # my($proto, $dbh, $table ) = @_;
55 # my $primary_key = '';
56 # my $sth = $dbh->prepare("SHOW INDEX FROM $table")
57 # or die $dbh->errstr;
58 # $sth->execute or die $sth->errstr;
59 # my @pkey = map { $_->{'Column_name'} } grep {
60 # $_->{'Key_name'} eq "PRIMARY"
61 # } @{ $sth->fetchall_arrayref( {} ) };
62 # scalar(@pkey) ? $pkey[0] : '';
66 my($proto, $dbh, $table) = @_;
67 my($pkey, $unique_href, $index_href) = $proto->_show_index($dbh, $table);
72 my($proto, $dbh, $table) = @_;
73 my($pkey, $unique_href, $index_href) = $proto->_show_index($dbh, $table);
78 my($proto, $dbh, $table) = @_;
79 my($pkey, $unique_href, $index_href) = $proto->_show_index($dbh, $table);
84 my($proto, $dbh, $table ) = @_;
85 my $sth = $dbh->prepare("SHOW INDEX FROM $table")
87 $sth->execute or die $sth->errstr;
91 foreach my $row ( @{ $sth->fetchall_arrayref({}) } ) {
92 if ( $row->{'Key_name'} eq 'PRIMARY' ) {
93 $pkey = $row->{'Column_name'};
94 } elsif ( $row->{'Non_unique'} ) { #index
95 push @{ $index{ $row->{'Key_name'} } }, $row->{'Column_name'};
97 push @{ $unique{ $row->{'Key_name'} } }, $row->{'Column_name'};
101 ( $pkey, \%unique, \%index );
106 Ivan Kohler <ivan-dbix-dbschema@420.am>
110 Copyright (c) 2000 Ivan Kohler
111 Copyright (c) 2000 Mail Abuse Prevention System LLC
113 This program is free software; you can redistribute it and/or modify it under
114 the same terms as Perl itself.
120 L<DBIx::DBSchema>, L<DBIx::DBSchema::DBD>, L<DBI>, L<DBI::DBD>