« lib/Genezzo/Contrib/Clustered/GLock/GLockDLM.pm
↑ Summary
lib/Genezzo/Contrib/Clustered/PrepUndo.pm »
| 1 | #!/usr/bin/perl | ||
| 2 | # | ||
| 3 | # genezzo_form.pl | ||
| 4 | # Eric Rollins 2005 | ||
| 5 | # | ||
| 6 | # This simple sample mod-perl script provides web access | ||
| 7 | # to Genezzo. The form is used to submit a SQL statement, | ||
| 8 | # And the results are returned as XML. | ||
| 9 | # | ||
| 10 | # It also demonstrates the use of SQL statements nested inside a page. | ||
| 11 | # This way pages act much like a stored procedure. The web page | ||
| 12 | # parameters are used like stored procedure parameters, and the | ||
| 13 | # processing on the page forms the transaction boundary. | ||
| 14 | |||
| 15 | # Prior to running this script a Genezzo database must be | ||
| 16 | # created. The script currently assumes the database was | ||
| 17 | # created using | ||
| 18 | # gendba.pl -gnz_home=/unsafe -init | ||
| 19 | # | ||
| 20 | # as user www-data. Prior to running this command the | ||
| 21 | # directory /unsafe must be created and www-data given | ||
| 22 | # permission to write it. | ||
| 23 | # | ||
| 24 | # The /unsafe directory is unsafe since any cgi-bin script can access it. | ||
| 25 | # | ||
| 26 | use strict; | ||
| 27 | use warnings; | ||
| 28 | |||
| 29 | use Genezzo::Contrib::Clustered::ModPerlWrap; | ||
| 30 | use CGI qw(:standard escapeHTML); | ||
| 31 | |||
| 32 | my $query = param('query'); | ||
| 33 | |||
| 34 | if(!defined($query)){ | ||
| 35 | PrintForm(); | ||
| 36 | } else { | ||
| 37 | StartPage(); | ||
| 38 | Connect("/unsafe"); | ||
| 39 | |||
| 40 | if($query eq "query_sample"){ | ||
| 41 | ProcessStmt("select * from t1"); | ||
| 42 | } elsif($query eq "insert_sample"){ | ||
| 43 | ProcessStmt("insert into t1 values (10, 'test10')"); | ||
| 44 | ProcessStmt("insert into t1 values (11, 'test11')"); | ||
| 45 | } else { | ||
| 46 | ProcessStmt($query); | ||
| 47 | } | ||
| 48 | |||
| 49 | Commit(); | ||
| 50 | FinishPage(); | ||
| 51 | } | ||
| 52 |