diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2012-09-24 10:15:50 +0000 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-26 13:46:46 +0000 |
commit | 485b97be9f2f2abf5a40923b5fd85f75714a8c02 (patch) | |
tree | ca05cb0ecf3828d909a898c3e5805804a0aff5f8 /t/05_select.t | |
download | perl-dbd-sqlite-tarball-master.tar.gz |
Imported from /srv/lorry/lorry-area/perl-dbd-sqlite-tarball/DBD-SQLite-1.38_01.tar.gz.HEADDBD-SQLite-1.38_01masterbaserock/morph
Diffstat (limited to 't/05_select.t')
-rw-r--r-- | t/05_select.t | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/t/05_select.t b/t/05_select.t new file mode 100644 index 0000000..73bd76b --- /dev/null +++ b/t/05_select.t @@ -0,0 +1,62 @@ +#!/usr/bin/perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use t::lib::Test; +use Test::More tests => 22; +use Test::NoWarnings; + +my $dbh = connect_ok( RaiseError => 1 ); +$dbh->do("CREATE TABLE f (f1, f2, f3)"); +my $sth = $dbh->prepare("INSERT INTO f VALUES (?, ?, ?)", { go_last_insert_id_args => [undef, undef, undef, undef] }); +$sth->execute("Fred", "Bloggs", "fred\@bloggs.com"); + +$sth = $dbh->prepare("SELECT * FROM f"); +ok($sth); +ok($sth->execute); +my $row = $sth->fetch; +ok($row); +is(@$row, 3); +my $rows = $sth->execute; +ok($rows); +ok($sth->fetch); +$sth->finish; +$sth = $dbh->prepare("INSERT INTO f (f1, f2, f3) VALUES (?, ?, ?)"); +ok($sth); +ok($sth->execute("test", "test", 1)); +$sth->finish; +$sth = $dbh->prepare("DELETE FROM f WHERE f3 = ?"); +ok($sth); +ok($sth->execute("1")); +$sth->finish; +$sth = $dbh->prepare("SELECT * FROM f"); +ok($sth); +ok($sth->execute()); +my $num_rows = 0; +while ($row = $sth->fetch) { + $num_rows++; +} +is($num_rows, 1, "Check num_rows ($num_rows) == 1"); +$sth->finish; +$dbh->do("delete from f where f1='test'"); +$sth = $dbh->prepare("INSERT INTO f (f1, f2, f3) VALUES (?, ?, ?)"); +ok($sth); +ok($sth->execute("test", "test", 1.05)); +$sth = $dbh->prepare("DELETE FROM f WHERE f3 = ?"); +ok($sth); +ok($sth->execute("1.05")); +$sth->finish; +$sth = $dbh->prepare("SELECT * FROM f"); +ok($sth); +ok($sth->execute()); +$num_rows = 0; +while ($row = $sth->fetch) { + $num_rows++; +} +ok($num_rows == 1); +$sth->finish; +$dbh->do("delete from f where f1='test'"); |