From: Aaron Trevena Date: Fri, 18 Apr 2008 08:18:26 +0000 (+0000) Subject: fixes for bug 29982 Inconsistency between examples and tutorial X-Git-Tag: 2.13~4 X-Git-Url: https://git.decadent.org.uk/gitweb/?p=maypole.git;a=commitdiff_plain;h=57b394571a593607a5b7a0ff4bdf9680461cd6a4 fixes for bug 29982 Inconsistency between examples and tutorial git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@588 48953598-375a-da11-a14b-00016c27c3ee --- diff --git a/examples/fancy_example/BeerDB.pm b/examples/fancy_example/BeerDB.pm index cb72574..427aee7 100644 --- a/examples/fancy_example/BeerDB.pm +++ b/examples/fancy_example/BeerDB.pm @@ -6,11 +6,23 @@ sub debug { $ENV{BEERDB_DEBUG} || 0 } # This is the sample application. Change this to the path to your # database. (or use mysql or something) use constant DBI_DRIVER => 'SQLite'; -use constant DATASOURCE => '/home/peter/Desktop/maypolebeer/beerdb'; +use constant DATASOURCE => $ENV{BEERDB_DATASOURCE} || 't/beerdb.db'; BeerDB->config->model('BeerDB::Base'); -BeerDB->setup("dbi:mysql:beerdb",'root', ''); +BEGIN { + my $dbi_driver = DBI_DRIVER; + if ($dbi_driver =~ /^SQLite/) { + unless -e (DATASOURCE) { + die sprintf("SQLite datasource '%s' not found, correct the path or recreate the database by running Makefile.PL", DATASOURCE), "\n"; + } + eval "require DBD::SQLite"; + if ($@) { + eval "require DBD::SQLite2" and $dbi_driver = 'SQLite2'; + } + } + BeerDB->setup(join ':', "dbi", $dbi_driver, DATASOURCE); +} # Give it a name. BeerDB->config->application_name('The Beer Database'); @@ -19,8 +31,7 @@ BeerDB->config->application_name('The Beer Database'); BeerDB->config->uri_base( $ENV{BEERDB_BASE} || "http://localhost/beerdb/" ); # Change this to the htdoc root for your maypole application. - -my @root= ('/home/peter/Desktop/maypolebeer/templates'); +my @root= ('t/templates'); push @root,$ENV{BEERDB_TEMPLATE_ROOT} if ($ENV{BEERDB_TEMPLATE_ROOT}); BeerDB->config->template_root( [@root] ); # Specify the rows per page in search results, lists, etc : 10 is a nice round number @@ -47,7 +58,7 @@ BeerDB::Pint->untaint_columns( printable => [qw/date_and_time/]); # Required Fields -BeerDB->config->{brewery}{required_cols} = [qw/name url/]; +BeerDB->config->{brewery}{required_cols} = [qw/name/]; BeerDB->config->{style}{required_cols} = [qw/name/]; BeerDB->config->{beer}{required_cols} = [qw/brewery name price/]; BeerDB->config->{pub}{required_cols} = [qw/name/]; diff --git a/examples/fancy_example/beerdb.sql b/examples/fancy_example/beerdb.sql index 6089c94..bd1b6d6 100644 --- a/examples/fancy_example/beerdb.sql +++ b/examples/fancy_example/beerdb.sql @@ -1,24 +1,24 @@ CREATE TABLE style ( - id integer primary key auto_increment, + id integer UNSIGNED NOT NULL primary key auto_increment, name varchar(60), notes text ); CREATE TABLE pub ( - id integer primary key auto_increment, + id integer UNSIGNED NOT NULLprimary key auto_increment, name varchar(60), url varchar(120), notes text ); CREATE TABLE handpump ( - id integer primary key auto_increment, + id integer UNSIGNED NOT NULL primary key auto_increment, beer integer, pub integer ); CREATE TABLE beer ( - id integer primary key auto_increment, + id integer UNSIGNED NOT NULL primary key auto_increment, brewery integer, style integer, name varchar(30), @@ -30,7 +30,7 @@ CREATE TABLE beer ( ); CREATE TABLE brewery ( - id integer primary key auto_increment, + id integer UNSIGNED NOT NULL primary key auto_increment, name varchar(30), url varchar(50), notes text