change test description in pdo_transaction.phpt

This commit is contained in:
v-kaywon 2017-04-13 13:00:54 -07:00
parent 0d4a2573d4
commit 18d26338ad

View file

@ -1,5 +1,6 @@
--TEST--
starts a transaction, delete rows and rollback the transaction
starts a transaction, delete rows and rollback the transaction then
starts a transaction, delete rows and commit
--SKIPIF--
--FILE--
@ -9,14 +10,14 @@ starts a transaction, delete rows and rollback the transaction
$conn = new PDO( "sqlsrv:Server=$serverName; Database = tempdb ", $username, $password);
$conn->exec("IF OBJECT_ID('Table1', 'U') IS NOT NULL DROP TABLE Table1");
$conn->exec("CREATE TABLE Table1(col1 CHARACTER(1), col2 CHARACTER(1)) ");
$conn->exec("CREATE TABLE Table1(col1 CHARACTER(1), col2 CHARACTER(1))");
$ret = $conn->exec("insert into Table1(col1, col2) values('a', 'b') ");
$ret = $conn->exec("insert into Table1(col1, col2) values('a', 'c') ");
$ret = $conn->exec("INSERT INTO Table1(col1, col2) VALUES('a', 'b')");
$ret = $conn->exec("INSERT INTO Table1(col1, col2) VALUES('a', 'c')");
//revert the inserts but roll back
$conn->beginTransaction();
$rows = $conn->exec("delete from Table1 where col1 = 'a'");
$rows = $conn->exec("DELETE FROM Table1 WHERE col1 = 'a'");
$conn->rollback();
$stmt = $conn->query("SELECT * FROM Table1");
@ -28,18 +29,18 @@ starts a transaction, delete rows and rollback the transaction
//revert the inserts then commit
$conn->beginTransaction();
$rows = $conn->exec("delete from Table1 where col1 = 'a'");
$rows = $conn->exec("DELETE FROM Table1 WHERE col1 = 'a'");
$conn->commit();
echo $rows." rows affected\n";
$stmt = $conn->query("select * from Table1");
$stmt = $conn->query("SELECT * FROM Table1");
if ( count( $stmt->fetchAll() ) == 0 )
echo "Transaction committed successfully\n";
else
echo "Transaction failed to commit\n";
//drop the created temp table
$conn->exec("DROP TABLE Table1 ");
$conn->exec("DROP TABLE Table1");
//free statement and connection
$stmt = NULL;