HTML::FormEngine::DBSQL

HTML::FormEngine::DBSQL can create html/xhtml forms.
Download

HTML::FormEngine::DBSQL Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Moritz Sinn
  • Publisher web site:
  • http://search.cpan.org/~morni/XML-ParseDTD-0.1.4/ParseDTD.pm

HTML::FormEngine::DBSQL Tags


HTML::FormEngine::DBSQL Description

HTML::FormEngine::DBSQL can create html/xhtml forms. HTML::FormEngine::DBSQL can create html/xhtml forms for adding, updating and removing records to / in / from sql database tables.SYNOPSISExample Code #!/usr/bin/perl -w use strict; use HTML::FormEngine::DBSQL; use DBI; use CGI; #use POSIX; #for setlocale #setlocale(LC_MESSAGES, 'german'); #for german error messages my $q = new CGI; print $q->header; my $dbh = DBI->connect('dbi:Pg:dbname=test', 'test', 'test'); my $Form = HTML::FormEngine::DBSQL->new(scalar $q->Vars, $dbh); $Form->dbsql_conf('user'); $Form->make(); print $q->start_html('FormEngine-dbsql example: User Administration'); if($Form->ok) { if($_ = $Form->dbsql_insert()) { print "Sucessfully added $_ user(s)!"; $Form->clear; } } print $Form->get, $q->end_html; $dbh->disconnect;Example Database TableExecute the following (Postgre)SQL commands to create the tables I used when developing the examples: CREATE SEQUENCE user_uid_seq; CREATE TABLE "user" ( uid integer DEFAULT nextval('user_uid_seq'::text) NOT NULL, name character varying(40) NOT NULL, forename character varying(40) NOT NULL, street character varying(40) NOT NULL, zip integer NOT NULL, town character varying(40) NOT NULL, email character varying(40) NOT NULL, phone character varying(15)[] DEFAULT '{"",""}'::character varying[], birthday date NOT NULL, newsletter boolean DEFAULT true ); CREATE TABLE login ( uid integer DEFAULT currval('user_uid_seq'::text) NOT NULL, username character varying(30) DEFAULT '-'::character varying NOT NULL, "password" character varying(30) DEFAULT '-'::character varying NOT NULL ); ALTER TABLE ONLY "user" ADD CONSTRAINT user_pkey PRIMARY KEY (uid); ALTER TABLE ONLY login ADD CONSTRAINT login_pkey PRIMARY KEY (uid); ALTER TABLE ONLY login ADD CONSTRAINT "$1" FOREIGN KEY (uid) REFERENCES "user"(uid) MATCH FULL ON UPDATE CASCADE ON DELETE CASCADE; COMMENT ON COLUMN "user".zip IS 'ERROR=digitonly;'; COMMENT ON COLUMN "user".email IS 'ERROR=rfc822;'; COMMENT ON COLUMN "user".phone IS 'display_as={{,}};ERROR_IN={{{not_null,digitonly},{not_null,digitonly}}};SUBTITLE={{,/}};SIZE={{5,10}};'; COMMENT ON COLUMN login.username IS 'ERROR={{regex,"must only contain A-Z, a-z and 0-9","^+$"},unique,dbsql_unique};'; COMMENT ON COLUMN login."password" IS 'TYPE=password;VALUE=;ERROR={{regex,"must have more than 4 chars",".{5,}"}};';Of course you can use any other table(s) as well. The file user.sql in the examples directory contains the whole database dump.Requirements:· Perl· HTML::FormEngine 1.0· Clone 0.13· Hash::Merge 0.07· Locale::gettext 1.01· Digest::MD5 2.24· DBI 1.42 Requirements: · Perl · HTML::FormEngine 1.0 · Clone 0.13 · Hash::Merge 0.07 · Locale::gettext 1.01 · Digest::MD5 2.24 · DBI 1.42


HTML::FormEngine::DBSQL Related Software