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

NAME

HTML::EP::EditTable - An HTML::EP extension for editing a table via WWW

SYNOPSIS

  <!-- Connect to the database --!>
  <ep-database dsn="DBI:mysql:test">
  <!-- Make HTML::EP edit your table: --!>
  <ep-edittable-edit table=MyTable>

DESCRIPTION

It is quite usual that you make your database tables editable via a WWW frontend. Writing such a frontend should be fast and simple for both the database administrator and the web designer.

HTML::EP::EditTable comes with a set of ready-to-use HTML files, suitable for an example table called Termine and an example subclass. Usually the Web designer just picks off the HTML files and modifies them until they fit his design wishes. Then the database administrator takes the files and usually just modifies the column names. If he wishes to add some private data checking or similar things, he can do so by subclassing the HTML::EP::Edittable class.

AVAILABLE METHODS

  <ep-edittable-edit table=MyTable id=ID what-to-do=insert>

This method combines the following possibilities:

  • Selecting a record out of the table MyTable.

  • Inserting a new record into the table MyTable.

  • Updating a record in the table MyTable.

  • Deleting a record from the table MyTable.

What the method exactly does, depends on the value of the CGI variable what-to-do: This can be either empty, insert, update or delete.

If what-to-do is insert or update, then the method will first call the HTML::EP method ep-input. If the attributes dest, prefix and sqlquery, which this method expects, are not set, then they will by default be set to MyTable, MyTable_ and 1, respectively.

If what-to-do is insert, then the query

  INSERT INTO MyTable ($@MyTable->names$) VALUES ($@MyTable->values$)

will be executed. Likewise, the query

  UPDATE MyTable SET $@MyTable->update WHERE ID = $cgi->ID$

will be executed for the value update.

If what-to-do is insert or delete, then the method will attempt to retrieve a row from the table MyTable. It does so, by looking at the column ID (default, you can overwrite this by setting the attribute id when calling the method) and the CGI variable of the same name, which contains the column ID, usually the primary key of the table.

The fetched row will be converted into the same format returned by ep-input: Thus you can always work with the same data format in all HTML pages.

SEE ALSO

HTML::EP(3), DBIx::RecordSet(3)