|
Packit |
723767 |
#!/usr/bin/perl
|
|
Packit |
723767 |
|
|
Packit |
723767 |
use strict;
|
|
Packit |
723767 |
BEGIN {
|
|
Packit |
723767 |
$| = 1;
|
|
Packit |
723767 |
$^W = 1;
|
|
Packit |
723767 |
}
|
|
Packit |
723767 |
|
|
Packit |
723767 |
use lib "t/lib";
|
|
Packit |
723767 |
use SQLiteTest;
|
|
Packit |
723767 |
use Test::More tests => 22;
|
|
Packit |
723767 |
use Test::NoWarnings;
|
|
Packit |
723767 |
|
|
Packit |
723767 |
my $dbh = connect_ok( RaiseError => 1 );
|
|
Packit |
723767 |
$dbh->do("CREATE TABLE f (f1, f2, f3)");
|
|
Packit |
723767 |
my $sth = $dbh->prepare("INSERT INTO f VALUES (?, ?, ?)", { go_last_insert_id_args => [undef, undef, undef, undef] });
|
|
Packit |
723767 |
$sth->execute("Fred", "Bloggs", "fred\@bloggs.com");
|
|
Packit |
723767 |
|
|
Packit |
723767 |
$sth = $dbh->prepare("SELECT * FROM f");
|
|
Packit |
723767 |
ok($sth);
|
|
Packit |
723767 |
ok($sth->execute);
|
|
Packit |
723767 |
my $row = $sth->fetch;
|
|
Packit |
723767 |
ok($row);
|
|
Packit |
723767 |
is(@$row, 3);
|
|
Packit |
723767 |
my $rows = $sth->execute;
|
|
Packit |
723767 |
ok($rows);
|
|
Packit |
723767 |
ok($sth->fetch);
|
|
Packit |
723767 |
$sth->finish;
|
|
Packit |
723767 |
$sth = $dbh->prepare("INSERT INTO f (f1, f2, f3) VALUES (?, ?, ?)");
|
|
Packit |
723767 |
ok($sth);
|
|
Packit |
723767 |
ok($sth->execute("test", "test", 1));
|
|
Packit |
723767 |
$sth->finish;
|
|
Packit |
723767 |
$sth = $dbh->prepare("DELETE FROM f WHERE f3 = ?");
|
|
Packit |
723767 |
ok($sth);
|
|
Packit |
723767 |
ok($sth->execute("1"));
|
|
Packit |
723767 |
$sth->finish;
|
|
Packit |
723767 |
$sth = $dbh->prepare("SELECT * FROM f");
|
|
Packit |
723767 |
ok($sth);
|
|
Packit |
723767 |
ok($sth->execute());
|
|
Packit |
723767 |
my $num_rows = 0;
|
|
Packit |
723767 |
while ($row = $sth->fetch) {
|
|
Packit |
723767 |
$num_rows++;
|
|
Packit |
723767 |
}
|
|
Packit |
723767 |
is($num_rows, 1, "Check num_rows ($num_rows) == 1");
|
|
Packit |
723767 |
$sth->finish;
|
|
Packit |
723767 |
$dbh->do("delete from f where f1='test'");
|
|
Packit |
723767 |
$sth = $dbh->prepare("INSERT INTO f (f1, f2, f3) VALUES (?, ?, ?)");
|
|
Packit |
723767 |
ok($sth);
|
|
Packit |
723767 |
ok($sth->execute("test", "test", 1.05));
|
|
Packit |
723767 |
$sth = $dbh->prepare("DELETE FROM f WHERE f3 = ?");
|
|
Packit |
723767 |
ok($sth);
|
|
Packit |
723767 |
ok($sth->execute("1.05"));
|
|
Packit |
723767 |
$sth->finish;
|
|
Packit |
723767 |
$sth = $dbh->prepare("SELECT * FROM f");
|
|
Packit |
723767 |
ok($sth);
|
|
Packit |
723767 |
ok($sth->execute());
|
|
Packit |
723767 |
$num_rows = 0;
|
|
Packit |
723767 |
while ($row = $sth->fetch) {
|
|
Packit |
723767 |
$num_rows++;
|
|
Packit |
723767 |
}
|
|
Packit |
723767 |
ok($num_rows == 1);
|
|
Packit |
723767 |
$sth->finish;
|
|
Packit |
723767 |
$dbh->do("delete from f where f1='test'");
|