diff options
| author | Ulf Wendel <uw@php.net> | 2011-07-26 15:37:59 +0000 |
|---|---|---|
| committer | Ulf Wendel <uw@php.net> | 2011-07-26 15:37:59 +0000 |
| commit | 8e3de07b4fa6a1b54efaa18b211be1530fdcbde6 (patch) | |
| tree | 57a41becf2a51f436421d34f6fb51a7ff7f48ef8 | |
| parent | 63ebb307305d4cdc91dc88d0665ee3360acaaa08 (diff) | |
| download | php-git-8e3de07b4fa6a1b54efaa18b211be1530fdcbde6.tar.gz | |
Check what happens if switching DB via API fails. Expected: no change of current DB/schema.
| -rw-r--r-- | ext/mysqli/tests/mysqli_select_db.phpt | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/ext/mysqli/tests/mysqli_select_db.phpt b/ext/mysqli/tests/mysqli_select_db.phpt index d700a2b557..b44487b24e 100644 --- a/ext/mysqli/tests/mysqli_select_db.phpt +++ b/ext/mysqli/tests/mysqli_select_db.phpt @@ -55,15 +55,33 @@ require_once('skipifconnectfailure.inc'); mysqli_free_result($res); } - mysqli_report(MYSQLI_REPORT_OFF); + if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname")) + printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!$row = mysqli_fetch_assoc($res)) + printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $current_db = $row['dbname']; + + mysqli_report(MYSQLI_REPORT_OFF); mysqli_select_db($link, 'I can not imagine that this database exists'); mysqli_report(MYSQLI_REPORT_ERROR); mysqli_select_db($link, 'I can not imagine that this database exists'); + if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname")) + printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!$row = mysqli_fetch_assoc($res)) + printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (strtolower($row['dbname']) != strtolower($current_db)) + printf("[016] Current DB should not change if set fails\n"); + + mysqli_close($link); if (NULL !== ($tmp = mysqli_select_db($link, $db))) - printf("[012] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + printf("[017] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); print "done!\n"; ?> |
