xref: /PHP-5.4/ext/pdo_firebird/tests/ddl.phpt (revision 4d6bae89)
1--TEST--
2PDO_Firebird: DDL/transactions
3--SKIPIF--
4<?php include("skipif.inc"); ?>
5<?php function_exists("ibase_query") or die("skip"); ?>
6--FILE--
7<?php /* $Id$ */
8
9	require("testdb.inc");
10
11	$db = new PDO("firebird:dbname=$test_base",$user,$password) or die;
12	$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
13
14	$db->exec("CREATE TABLE ddl (id INT NOT NULL PRIMARY KEY, text BLOB SUB_TYPE 1)");
15	$db->exec("CREATE GENERATOR gen_ddl_id");
16	$db->exec("CREATE TRIGGER ddl_bi FOR ddl BEFORE INSERT AS
17		BEGIN IF (NEW.id IS NULL) THEN NEW.id=GEN_ID(gen_ddl_id,1); END");
18
19	$db->setAttribute(PDO::ATTR_AUTOCOMMIT,0);
20
21	$db->beginTransaction();
22	var_dump($db->exec("INSERT INTO ddl (text) VALUES ('bla')"));
23	var_dump($db->exec("UPDATE ddl SET text='blabla'"));
24	$db->rollback();
25
26	$db->beginTransaction();
27	var_dump($db->exec("DELETE FROM ddl"));
28	$db->commit();
29
30	unset($db);
31	echo "done\n";
32
33?>
34--EXPECT--
35int(1)
36int(1)
37int(0)
38done
39