X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=examples%2FSchema%2Ftestdb.pl;h=0149bc2abbdb284af2bfc9d7ec7bc9c3f78574e9;hb=07a243ad8f4273317a028eb7a55a8682a713eba3;hp=a65db0fdf332c9fb9c76d16ec5fc8ddcaa995f24;hpb=a8b66abc9cf90221ebcd9be535eda47f6b37a6f8;p=dbsrgits%2FDBIx-Class.git diff --git a/examples/Schema/testdb.pl b/examples/Schema/testdb.pl old mode 100644 new mode 100755 index a65db0f..0149bc2 --- a/examples/Schema/testdb.pl +++ b/examples/Schema/testdb.pl @@ -3,11 +3,14 @@ use warnings; use strict; -use MyDatabase::Main; +use MyApp::Schema; +use DBIx::Class::_Util 'parent_dir'; + +my $db_fn = parent_dir( $INC{'MyApp/Schema.pm'} ) . '../db/example.db'; -my $schema = MyDatabase::Main->connect('dbi:SQLite:db/example.db'); # for other DSNs, e.g. MySql, see the perldoc for the relevant dbd # driver, e.g perldoc L. +my $schema = MyApp::Schema->connect("dbi:SQLite:$db_fn"); get_tracks_by_cd('Bad'); get_tracks_by_artist('Michael Jackson'); @@ -50,7 +53,8 @@ sub get_tracks_by_artist { } ); while (my $track = $rs->next) { - print $track->title . "\n"; + print $track->title . " (from the CD '" . $track->cd->title + . "')\n"; } print "\n"; } @@ -67,7 +71,7 @@ sub get_cd_by_track { } ); my $cd = $rs->first; - print $cd->title . "\n\n"; + print $cd->title . " has the track '$tracktitle'.\n\n"; } sub get_cds_by_artist { @@ -101,7 +105,7 @@ sub get_artist_by_track { } ); my $artist = $rs->first; - print $artist->name . "\n\n"; + print $artist->name . " recorded the track '$tracktitle'.\n\n"; } sub get_artist_by_cd { @@ -116,5 +120,5 @@ sub get_artist_by_cd { } ); my $artist = $rs->first; - print $artist->name . "\n\n"; + print $artist->name . " recorded the CD '$cdtitle'.\n\n"; }