This commit was generated by cvs2svn to compensate for changes in r3921,
[freeside.git] / install / 5.005 / DBD-Pg-1.22-fixvercmp / t / 03bind.t
1 use strict;
2 use DBI;
3 use Test::More;
4
5 if (defined $ENV{DBI_DSN}) {
6   plan tests => 11;
7 } else {
8   plan skip_all => 'cannot test without DB info';
9 }
10
11 my $dbh = DBI->connect($ENV{DBI_DSN}, $ENV{DBI_USER}, $ENV{DBI_PASS},
12                        {RaiseError => 1, AutoCommit => 0}
13                       );
14 ok(defined $dbh,
15    'connect with transaction'
16   );
17
18 my $sql = <<SQL;
19   SELECT id
20   , name
21   FROM test
22   WHERE id = ?
23 SQL
24 my $sth = $dbh->prepare($sql);
25 ok(defined $sth,
26    "prepare: $sql"
27   );
28
29 ok($sth->bind_param(1, 'foo'),
30    'bind int column with string'
31    );
32
33 ok($sth->bind_param(1, 1),
34    'rebind int column with int'
35    );
36
37 $sql = <<SQL;
38    SELECT id
39    , name
40    FROM test
41    WHERE id = ?
42    AND name = ?
43 SQL
44 $sth = $dbh->prepare($sql);
45 ok(defined $sth,
46    "prepare: $sql"
47   );
48
49 ok($sth->bind_param(1, 'foo'),
50    'bind int column with string',
51   );
52 ok($sth->bind_param(2, 'bar'),
53    'bind string column with text'
54    );
55 ok($sth->bind_param(2, 'baz'),
56    'rebind string column with text'
57   );
58
59 ok($sth->finish(),
60    'finish'
61    );
62
63 # Make sure that we get warnings when we try to use SQL_BINARY.
64 {
65   local $SIG{__WARN__} =
66     sub { ok($_[0] =~ /^Use of SQL type SQL_BINARY/,
67              'warning with SQL_BINARY'
68             );
69         };
70
71   $sql = <<SQL;
72          SELECT id
73          , name
74          FROM test
75          WHERE id = ?
76          AND name = ?
77 SQL
78   $sth = $dbh->prepare($sql);
79
80   $sth->bind_param(1, 'foo', DBI::SQL_BINARY);
81 }
82
83 ok($dbh->disconnect(),
84    'disconnect'
85   );