uw Tue, 26 Jul 2011 16:14:59 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=313738
Log:
Double check if line is sill usable and connected to last successfully selected
db.
Changed paths:
U php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_select_db.phpt
U php/php-src/branches/PHP_5_4/ext/mysqli/tests/mysqli_select_db.phpt
U php/php-src/trunk/ext/mysqli/tests/mysqli_select_db.phpt
Modified: php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_select_db.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_select_db.phpt
2011-07-26 15:37:59 UTC (rev 313737)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_select_db.phpt
2011-07-26 16:14:59 UTC (rev 313738)
@@ -9,6 +9,7 @@
--FILE--
<?php
require_once("connect.inc");
+ require_once("table.inc");
$tmp = NULL;
$link = NULL;
@@ -55,11 +56,14 @@
mysqli_free_result($res);
}
+ if (!$link->select_db($db))
+ printf("[012] Failed to set '%s' as current DB; [%d] %s\n",
$link->errno, $link->error);
+
if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
- printf("[012] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+ printf("[013] [%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));
+ printf("[014] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
$current_db = $row['dbname'];
@@ -69,15 +73,21 @@
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));
+ printf("[015] [%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));
+ printf("[016] [%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");
+ printf("[017] Current DB should not change if set fails\n");
+
+ if (!$res = $link->query("SELECT id FROM test WHERE id = 1"))
+ printf("[018] [%d] %s\n");
+ $row = $res->fetch_assoc();
+ $res->free();
+
mysqli_close($link);
if (NULL !== ($tmp = mysqli_select_db($link, $db)))
@@ -85,6 +95,8 @@
print "done!\n";
?>
+--CLEAN--
+<?php require_once("clean_table.inc"); ?>
--EXPECTF--
Warning: mysqli_select_db(): (%d/%d): Unknown database '%s' in %s on line %d
Modified: php/php-src/branches/PHP_5_4/ext/mysqli/tests/mysqli_select_db.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/mysqli/tests/mysqli_select_db.phpt
2011-07-26 15:37:59 UTC (rev 313737)
+++ php/php-src/branches/PHP_5_4/ext/mysqli/tests/mysqli_select_db.phpt
2011-07-26 16:14:59 UTC (rev 313738)
@@ -9,6 +9,7 @@
--FILE--
<?php
require_once("connect.inc");
+ require_once("table.inc");
$tmp = NULL;
$link = NULL;
@@ -55,11 +56,14 @@
mysqli_free_result($res);
}
+ if (!$link->select_db($db))
+ printf("[012] Failed to set '%s' as current DB; [%d] %s\n",
$link->errno, $link->error);
+
if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
- printf("[012] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+ printf("[013] [%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));
+ printf("[014] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
$current_db = $row['dbname'];
@@ -69,15 +73,21 @@
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));
+ printf("[015] [%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));
+ printf("[016] [%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");
+ printf("[017] Current DB should not change if set fails\n");
+
+ if (!$res = $link->query("SELECT id FROM test WHERE id = 1"))
+ printf("[018] [%d] %s\n");
+ $row = $res->fetch_assoc();
+ $res->free();
+
mysqli_close($link);
if (NULL !== ($tmp = mysqli_select_db($link, $db)))
@@ -85,6 +95,8 @@
print "done!\n";
?>
+--CLEAN--
+<?php require_once("clean_table.inc"); ?>
--EXPECTF--
Warning: mysqli_select_db(): (%d/%d): Unknown database '%s' in %s on line %d
Modified: php/php-src/trunk/ext/mysqli/tests/mysqli_select_db.phpt
===================================================================
--- php/php-src/trunk/ext/mysqli/tests/mysqli_select_db.phpt 2011-07-26
15:37:59 UTC (rev 313737)
+++ php/php-src/trunk/ext/mysqli/tests/mysqli_select_db.phpt 2011-07-26
16:14:59 UTC (rev 313738)
@@ -9,6 +9,7 @@
--FILE--
<?php
require_once("connect.inc");
+ require_once("table.inc");
$tmp = NULL;
$link = NULL;
@@ -55,11 +56,14 @@
mysqli_free_result($res);
}
+ if (!$link->select_db($db))
+ printf("[012] Failed to set '%s' as current DB; [%d] %s\n",
$link->errno, $link->error);
+
if (!$res = mysqli_query($link, "SELECT DATABASE() AS dbname"))
- printf("[012] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
+ printf("[013] [%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));
+ printf("[014] [%d] %s\n", mysqli_errno($link),
mysqli_error($link));
$current_db = $row['dbname'];
@@ -69,15 +73,21 @@
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));
+ printf("[015] [%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));
+ printf("[016] [%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");
+ printf("[017] Current DB should not change if set fails\n");
+
+ if (!$res = $link->query("SELECT id FROM test WHERE id = 1"))
+ printf("[018] [%d] %s\n");
+ $row = $res->fetch_assoc();
+ $res->free();
+
mysqli_close($link);
if (NULL !== ($tmp = mysqli_select_db($link, $db)))
@@ -85,6 +95,8 @@
print "done!\n";
?>
+--CLEAN--
+<?php require_once("clean_table.inc"); ?>
--EXPECTF--
Warning: mysqli_select_db(): (%d/%d): Unknown database '%s' in %s on line %d
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php