Created
August 6, 2009 05:40
-
-
Save ryan5500/163157 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# | |
# Database CRUD test using DBIx::Class module | |
# | |
use strict; | |
use My::Schema; | |
my $schema = My::Schema->connect('dbi:SQLite:./test.db'); | |
# [C]RUD: create new row at 'Album' table | |
my $new_album = $schema->resultset('Album')->create({ | |
title => 'Wish You Were Here', | |
artist => 'Pink Floyd' | |
}); | |
print "new album title:" . $new_album->title . "\n"; | |
# C[R]UD: read table 'Album' from database | |
my $album = $schema->resultset('Album')->find(1); | |
print "album number1 title:" . $album->title . "\n"; | |
# CR[U]D: update Album table's 'title' row | |
$album->title('sounds bad'); | |
$album->update; | |
print "album number1 title:" . $album->title . "\n"; | |
# CRU[D]: delete Album table's row | |
$new_album->delete; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment