php-src/ext/mysqli/tests/mysqli_stmt_bind_param_many_columns.phpt

77 lines
2.2 KiB
Plaintext
Raw Normal View History

--TEST--
mysqli_stmt_bind_param() - Binding with very high number of columns
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
/*
The way we test the INSERT and data types overlaps with
the mysqli_stmt_bind_result test in large parts. There is only
one difference. This test uses mysqli_query()/mysqli_fetch_assoc() to
fetch the inserted values. This way we test
mysqli_query()/mysqli_fetch_assoc() for all possible data types
in this file and we test mysqli_stmt_bind_result() in the other
test -- therefore the "duplicate" makes some sense to me.
*/
require_once("connect.inc");
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
exit(1);
}
if (!mysqli_query($link, 'DROP TABLE IF EXISTS ps_test')) {
printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
exit(1);
}
$cols = 2500;
$str = array();
for ($i = 1; $i <= $cols; $i++) {
$str[] ="a$i INT";
}
$link->query("CREATE TABLE ps_test(" . implode(" , ", $str) . ")");
if (mysqli_errno($link)) {
printf("Failed to create the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
die("");
}
$stmt = $link->prepare("INSERT INTO ps_test VALUES(".str_repeat("?, ", $cols-1) . "?)");
var_dump($stmt->id);
$eval_str="\$stmt->bind_param(\"".str_repeat("i",$cols)."\", ";
for ($i = 1; $i < $cols; $i++) {
$eval_str.="\$i,";
}
$eval_str.="\$i";
$eval_str.=");";
eval($eval_str);
var_dump($stmt->execute());
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
exit(1);
}
if (!mysqli_query($link, 'DROP TABLE IF EXISTS ps_test')) {
printf("Failed to drop the test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
exit(1);
}
?>
--EXPECTF--
int(1)
bool(true)
done!