1--TEST-- 2mysqli_savepoint() 3--EXTENSIONS-- 4mysqli 5--SKIPIF-- 6<?php 7require_once('skipifconnectfailure.inc'); 8 9require_once('connect.inc'); 10if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 11 die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error())); 12 13if (!have_innodb($link)) 14 die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error)); 15?> 16--FILE-- 17<?php 18 require_once("connect.inc"); 19 20 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 21 printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", 22 $host, $user, $db, $port, $socket); 23 24 try { 25 mysqli_savepoint($link, ''); 26 } catch (\ValueError $e) { 27 echo $e->getMessage() . \PHP_EOL; 28 } 29 30 if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) 31 printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 32 33 if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB')) 34 printf("[008] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 35 36 if (true !== ($tmp = mysqli_autocommit($link, false))) 37 printf("[009] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp); 38 39 /* overrule autocommit */ 40 if (true !== ($tmp = mysqli_savepoint($link, 'my'))) 41 printf("[010] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link)); 42 43 if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)')) 44 printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 45 46 $tmp = mysqli_rollback($link); 47 if ($tmp !== true) 48 printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); 49 50 print "done!"; 51?> 52--CLEAN-- 53<?php 54 require_once("clean_table.inc"); 55?> 56--EXPECT-- 57mysqli_savepoint(): Argument #2 ($name) cannot be empty 58done! 59