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',
16 DBIx::DBSchema::DBD::mysql - MySQL native driver for DBIx::DBSchema
23 $dbh = DBI->connect('dbi:mysql:database', 'user', 'pass');
24 $schema = new_native DBIx::DBSchema $dbh;
28 This module implements a MySQL-native driver for DBIx::DBSchema.
33 my($proto, $dbh, $table ) = @_;
34 my $sth = $dbh->prepare("SHOW COLUMNS FROM $table") or die $dbh->errstr;
35 $sth->execute or die $sth->errstr;
37 $_->{'Type'} =~ /^(\w+)\(?([\d\,]+)?\)?( unsigned)?$/
38 or die "Illegal type: ". $_->{'Type'}. "\n";
39 my($type, $length) = ($1, $2);
48 } @{ $sth->fetchall_arrayref( {} ) };
52 # my($proto, $dbh, $table ) = @_;
53 # my $primary_key = '';
54 # my $sth = $dbh->prepare("SHOW INDEX FROM $table")
55 # or die $dbh->errstr;
56 # $sth->execute or die $sth->errstr;
57 # my @pkey = map { $_->{'Column_name'} } grep {
58 # $_->{'Key_name'} eq "PRIMARY"
59 # } @{ $sth->fetchall_arrayref( {} ) };
60 # scalar(@pkey) ? $pkey[0] : '';
64 my($proto, $dbh, $table) = @_;
65 my($pkey, $unique_href, $index_href) = $proto->_show_index($dbh, $table);
70 my($proto, $dbh, $table) = @_;
71 my($pkey, $unique_href, $index_href) = $proto->_show_index($dbh, $table);
76 my($proto, $dbh, $table) = @_;
77 my($pkey, $unique_href, $index_href) = $proto->_show_index($dbh, $table);
82 my($proto, $dbh, $table ) = @_;
83 my $sth = $dbh->prepare("SHOW INDEX FROM $table")
85 $sth->execute or die $sth->errstr;
89 foreach my $row ( @{ $sth->fetchall_arrayref({}) } ) {
90 if ( $row->{'Key_name'} eq 'PRIMARY' ) {
91 $pkey = $row->{'Column_name'};
92 } elsif ( $row->{'Non_unique'} ) { #index
93 push @{ $index{ $row->{'Key_name'} } }, $row->{'Column_name'};
95 push @{ $unique{ $row->{'Key_name'} } }, $row->{'Column_name'};
99 ( $pkey, \%unique, \%index );
104 Ivan Kohler <ivan-dbix-dbschema@420.am>
108 Copyright (c) 2000 Ivan Kohler
109 Copyright (c) 2000 Mail Abuse Prevention System LLC
111 This program is free software; you can redistribute it and/or modify it under
112 the same terms as Perl itself.
118 L<DBIx::DBSchema>, L<DBIx::DBSchema::DBD>, L<DBI>, L<DBI::DBD>