X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=examples%2FSchema%2Ftestdb.pl;h=0149bc2abbdb284af2bfc9d7ec7bc9c3f78574e9;hb=86a432d4cc096062e2374f118ce38aa131799d6a;hp=c608f459d750a295742fb48cecf5436d631f86c3;hpb=f54428abf9cc7d7e5604745335694eaf558f6820;p=dbsrgits%2FDBIx-Class.git diff --git a/examples/Schema/testdb.pl b/examples/Schema/testdb.pl old mode 100644 new mode 100755 index c608f45..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,12 +53,12 @@ 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"; } - sub get_cd_by_track { my $tracktitle = shift; print "get_cd_by_track($tracktitle):\n"; @@ -68,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 { @@ -88,8 +91,6 @@ sub get_cds_by_artist { print "\n"; } - - sub get_artist_by_track { my $tracktitle = shift; print "get_artist_by_track($tracktitle):\n"; @@ -104,10 +105,9 @@ 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 { my $cdtitle = shift; print "get_artist_by_cd($cdtitle):\n"; @@ -120,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"; }