mirror of
https://github.com/php/php-src.git
synced 2025-08-20 09:24:05 +02:00
Sync from 5_3. Cutting off a few edges:
- use connection parameter from environment variables - check if MySQL supports procedures - whitespace
This commit is contained in:
parent
9f4a22f1a8
commit
5e64d2273e
1 changed files with 35 additions and 21 deletions
|
@ -1,43 +1,56 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Bug #42548 PROCEDURE xxx can't return a result set in the given context (works in 5.2.3!!)
|
Bug #42548 PROCEDURE xxx can't return a result set in the given context (works in 5.2.3!!)
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php if (!extension_loaded("mysqli")) print "skip"; ?>
|
<?php
|
||||||
|
require_once('skipif.inc');
|
||||||
|
require_once('skipifconnectfailure.inc');
|
||||||
|
require_once('connect.inc');
|
||||||
|
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
|
||||||
|
die(sprintf('skip Cannot connect to MySQL, [%d] %s.', mysqli_connect_errno(), mysqli_connect_error()));
|
||||||
|
}
|
||||||
|
if (mysqli_get_server_version($link) <= 50000) {
|
||||||
|
die(sprintf('skip Needs MySQL 5.0+, found version %d.', mysqli_get_server_version($link)));
|
||||||
|
}
|
||||||
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
require_once('connect.inc');
|
||||||
|
|
||||||
$mysqli = mysqli_init();
|
$mysqli = mysqli_init();
|
||||||
$mysqli->real_connect('localhost', 'root', '', 'test');
|
$mysqli->real_connect($host, $user, $passwd, $db, $port, $socket);
|
||||||
if (mysqli_connect_errno()) {
|
if (mysqli_connect_errno()) {
|
||||||
printf("Connect failed: %s\n", mysqli_connect_error());
|
printf("Connect failed: %s\n", mysqli_connect_error());
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$mysqli->query("DROP PROCEDURE IF EXISTS p1") or die($mysqli->error);
|
$mysqli->query("DROP PROCEDURE IF EXISTS p1") or die($mysqli->error);
|
||||||
$mysqli->query("CREATE PROCEDURE p1() BEGIN SELECT 23; SELECT 42; END") or die($mysqli->error);
|
$mysqli->query("CREATE PROCEDURE p1() BEGIN SELECT 23; SELECT 42; END") or die($mysqli->error);
|
||||||
|
|
||||||
if ($mysqli->multi_query("CALL p1();"))
|
if ($mysqli->multi_query("CALL p1();"))
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ($objResult = $mysqli->store_result()) {
|
if ($objResult = $mysqli->store_result()) {
|
||||||
while ($row = $objResult->fetch_assoc()) {
|
while ($row = $objResult->fetch_assoc()) {
|
||||||
print_r($row);
|
print_r($row);
|
||||||
}
|
}
|
||||||
$objResult->close();
|
$objResult->close();
|
||||||
if ($mysqli->more_results()) {
|
if ($mysqli->more_results()) {
|
||||||
print "----- next result -----------\n";
|
print "----- next result -----------\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print "no results found";
|
print "no results found\n";
|
||||||
}
|
}
|
||||||
} while ($mysqli->more_results() && $mysqli->next_result());
|
} while ($mysqli->more_results() && $mysqli->next_result());
|
||||||
} else {
|
} else {
|
||||||
print $mysqli->error;
|
print $mysqli->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mysqli->query("DROP PROCEDURE p1") or die($mysqli->error);
|
$mysqli->query("DROP PROCEDURE p1") or die($mysqli->error);
|
||||||
$mysqli->close();
|
$mysqli->close();
|
||||||
|
print "done!";
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Array
|
Array
|
||||||
(
|
(
|
||||||
[23] => 23
|
[23] => 23
|
||||||
|
@ -49,3 +62,4 @@ Array
|
||||||
)
|
)
|
||||||
----- next result -----------
|
----- next result -----------
|
||||||
no results found
|
no results found
|
||||||
|
done!
|
Loading…
Add table
Add a link
Reference in a new issue