xref: /PHP-8.3/ext/pdo_firebird/tests/ddl.phpt (revision b5a14e6c)
1--TEST--
2PDO_Firebird: DDL/transactions
3--EXTENSIONS--
4pdo_firebird
5--SKIPIF--
6<?php require('skipif.inc'); ?>
7--ENV--
8LSAN_OPTIONS=detect_leaks=0
9--FILE--
10<?php
11
12    require("testdb.inc");
13
14    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
15
16    @$dbh->exec('DROP TABLE ddl');
17    @$dbh->exec('DROP GENERATOR gen_ddl_id');
18    @$dbh->exec('DROP TRIGGER ddl_bi');
19
20    $dbh->exec("CREATE TABLE ddl (id INT NOT NULL PRIMARY KEY, text BLOB SUB_TYPE 1)");
21    $dbh->exec("CREATE GENERATOR gen_ddl_id");
22    $dbh->exec("CREATE TRIGGER ddl_bi FOR ddl BEFORE INSERT AS
23        BEGIN IF (NEW.id IS NULL) THEN NEW.id=GEN_ID(gen_ddl_id,1); END");
24
25    $dbh->setAttribute(PDO::ATTR_AUTOCOMMIT,0);
26
27    $dbh->beginTransaction();
28    var_dump($dbh->exec("INSERT INTO ddl (text) VALUES ('bla')"));
29    var_dump($dbh->exec("UPDATE ddl SET text='blabla'"));
30    $dbh->rollback();
31
32    $dbh->beginTransaction();
33    var_dump($dbh->exec("DELETE FROM ddl"));
34    $dbh->commit();
35
36    unset($dbh);
37    echo "done\n";
38
39?>
40--EXPECT--
41int(1)
42int(1)
43int(0)
44done
45