File: 05_select.t

package info (click to toggle)
libdbd-sqlite3-perl 1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,004 kB
  • sloc: ansic: 167,715; perl: 1,788; pascal: 277; makefile: 9
file content (59 lines) | stat: -rw-r--r-- 1,481 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use strict;
use warnings;
use lib "t/lib";
use SQLiteTest;
use Test::More;
use if -d ".git", "Test::FailWarnings";

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'");

done_testing;