The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DBIx::CGITables::MakeTemplates - creates templates for CGITables.

SYNOPSIS

  cd /path/to/webserver/document_root/wherever/the/templates/should/be

  mysqldump -d mydatabase > /tmp/schema.dd
  echo '-- END' >> /tmp/schema.dd
  vi /tmp/schema.dd
  perl -MDBIx::CGITables::MakeTemplates -e 'make "dbi:mysql:test:localhost"'< /tmp/schema.dd

DESCRIPTION

This is under construction, there might be code stubs, some of the announced features might be missing, and if you're more unlucky it might not work at all. Feedback will probably speed up my work on this.

This module takes its input from a set of data definitions (SQL `create table' statements), and generates templates and parameter files for the tables. The data definition file should be edited slightly before running MakeTemplates.

The most important thing about the hand-editing is to deal with the foreign keys. Mysql doesn't have them at all, so they will eventually have to be manually added. If there is a "Foreign key (foreign_id)..."-line, then the attribute line (typically something like "foreign_id integer") should be removed - eventually the other way.

Attributes might be added to describe how to handle attributes and foreign keys - unfortunately I don't have time documenting them at the moment.

Eventually, the module should work without any editing of the DD at all, just reading the eventual extra configuration information from an extra file.

The module will produce three files; the form template ($dbname.$tablename.dbt), the list template ($dbname.$tablename.found_more.dbt) and the parameter file ($dbname.$tablename.param.dbt).

About foreign keys (not implemented yet);

Mysql doesn't have them - so if links are needed, the dd code needs to be modified. The dd code should be modified anyway. In a create table statement, the attribute should first be declared (i.e. `user_id integer'), and later it should be declared that it's a foreign key. One of those lines should be deleted - you will probably want to remove the attribute declaration (the foreign key will be respected), alternatively the foreign key declaration (letting the foreign key be threated as just another attribute).

KNOWN BUGS

This is just some loose hacks. This is under construction (maybe it would be even better to start from scratch redoing it). This is absolutely not tested very well. It is not a SQL parser, and it's only tested for the output from mysql and solid. It's linebreak sensitive, so it might not be compatible with other DBMSs. Foreign keys are not supported yet. This documentation sucks. The code sucks. Well.

AUTHOR

Tobias Brox <tobiasb@funcom.com>