xref: /php-src/ext/pdo_firebird/tests/execute.phpt (revision d6a0b3af)
1--TEST--
2PDO_Firebird: prepare/execute/binding
3--EXTENSIONS--
4pdo_firebird
5--SKIPIF--
6<?php require('skipif.inc'); ?>
7--XLEAK--
8A bug in firebird causes a memory leak when calling `isc_attach_database()`.
9See https://github.com/FirebirdSQL/firebird/issues/7849
10--FILE--
11<?php
12require("testdb.inc");
13
14$dbh = getDbConnection();
15var_dump($dbh->getAttribute(PDO::ATTR_CONNECTION_STATUS));
16
17$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
18$dbh->setAttribute(PDO::FB_ATTR_TIMESTAMP_FORMAT, '%Y-%m-%d %H:%M:%S');
19
20$dbh->exec("CREATE TABLE test_execute (id SMALLINT NOT NULL PRIMARY KEY, text VARCHAR(32),
21    datetime TIMESTAMP DEFAULT '2000-02-12' NOT NULL)");
22$dbh->exec("INSERT INTO test_execute (id,text) VALUES (1,'bla')");
23
24$s = $dbh->prepare("SELECT * FROM test_execute WHERE id=? FOR UPDATE");
25
26$id = 0;
27$s->bindParam(1,$id);
28$var = null;
29$s->bindColumn("TEXT",$var);
30$id = 1;
31$s->execute();
32$s->setAttribute(PDO::ATTR_CURSOR_NAME, "c");
33
34var_dump($id);
35
36var_dump($s->fetch());
37
38var_dump($var);
39
40var_dump($dbh->exec("UPDATE test_execute SET id=2 WHERE CURRENT OF c"));
41
42var_dump($s->fetch());
43
44unset($s);
45unset($dbh);
46echo "done\n";
47?>
48--CLEAN--
49<?php
50require 'testdb.inc';
51$dbh = getDbConnection();
52@$dbh->exec('DROP TABLE test_execute');
53unset($dbh);
54--EXPECT--
55bool(true)
56int(1)
57array(6) {
58  ["ID"]=>
59  int(1)
60  [0]=>
61  int(1)
62  ["TEXT"]=>
63  string(3) "bla"
64  [1]=>
65  string(3) "bla"
66  ["DATETIME"]=>
67  string(19) "2000-02-12 00:00:00"
68  [2]=>
69  string(19) "2000-02-12 00:00:00"
70}
71string(3) "bla"
72int(1)
73bool(false)
74done
75