##
use DBI;
use SQL::DBIforms;
my $connect_file = '/etc/www/.mysql.www';
my $dbh = DBI->connect( "DBI:mysql:database=userish;host=localhost;" .
"mysql_read_default_file=$connect_file;" );
my $db_fields = SQL::DBIforms::make_form_fields($dbh, 'userish');
for my $field ( @{db_fields} ) {
next if $field->type eq 'DATE'; # want to stamp in background
print
$field . ": \n",
ucfirst $field->form_field,
$field->is_required ? ' (required)' : '', # for NOT NULL
"\n\n";
}
##
##
Id:
(required)
User:
##
use Data::Dumper;
sub make_form_fields {
my ( $dbh, $table ) = @_;
my $sth = $dbh->prepare
(qq{
DESCRIBE ?;
});
my $table_info = $dbh->selectall_arrayref($sth, $ATTR, $table);
# then parse that structure to get info and turn it into an array of field objects
# NOT NULL would set a required flag
# DEFAULT value would drop into same for field and so on
# I haven't written the parsing, just playing still so a cop out...
return = "", Dumper($table), "
\n";
}