2003-02-12 08:46:29 +08:00
|
|
|
--TEST--
|
2005-11-28 21:35:54 +08:00
|
|
|
mysqli fetch bigint values (ok to fail with 4.1.x)
|
2004-12-04 16:50:33 +08:00
|
|
|
--SKIPIF--
|
2005-07-20 08:18:24 +08:00
|
|
|
<?php
|
|
|
|
if (PHP_INT_SIZE == 8) {
|
|
|
|
echo 'skip test valid only for 32bit systems';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
require_once('skipif.inc');
|
2007-10-10 18:06:53 +08:00
|
|
|
require_once('skipifconnectfailure.inc');
|
2005-07-20 08:18:24 +08:00
|
|
|
?>
|
2003-02-12 08:46:29 +08:00
|
|
|
--FILE--
|
|
|
|
<?php
|
2009-10-20 04:07:25 +08:00
|
|
|
require_once("connect.inc");
|
2007-10-10 18:06:53 +08:00
|
|
|
|
2003-02-12 08:46:29 +08:00
|
|
|
/*** test mysqli_connect 127.0.0.1 ***/
|
2009-09-24 20:51:03 +08:00
|
|
|
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
|
2007-10-10 18:06:53 +08:00
|
|
|
|
|
|
|
if (!mysqli_query($link, "SET sql_mode=''"))
|
|
|
|
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
2003-02-12 08:46:29 +08:00
|
|
|
|
2007-10-10 18:06:53 +08:00
|
|
|
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
|
|
|
|
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
2003-02-12 08:46:29 +08:00
|
|
|
|
2007-10-10 18:06:53 +08:00
|
|
|
$rc = mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 bigint default 5,
|
|
|
|
c2 bigint,
|
|
|
|
c3 bigint not NULL,
|
|
|
|
c4 bigint unsigned,
|
|
|
|
c5 bigint unsigned,
|
|
|
|
c6 bigint unsigned,
|
|
|
|
c7 bigint unsigned,
|
|
|
|
c8 bigint unsigned) ENGINE=" . $engine);
|
|
|
|
if (!$rc)
|
|
|
|
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
2003-02-12 08:46:29 +08:00
|
|
|
|
2007-10-10 18:06:53 +08:00
|
|
|
$rc = mysqli_query($link, "INSERT INTO test_bind_fetch (c2,c3,c4,c5,c6,c7,c8) ".
|
|
|
|
"VALUES (-23,4.0,33333333333333,0,-333333333333,99.9,1234)");
|
|
|
|
if (!$rc)
|
|
|
|
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
2003-02-12 08:46:29 +08:00
|
|
|
|
|
|
|
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
2010-09-23 22:59:13 +08:00
|
|
|
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
|
|
|
|
mysqli_stmt_execute($stmt);
|
|
|
|
$rc = mysqli_stmt_fetch($stmt);
|
2003-02-12 08:46:29 +08:00
|
|
|
|
2007-10-10 18:06:53 +08:00
|
|
|
if (mysqli_get_server_version($link) < 50000) {
|
|
|
|
// 4.1 is faulty and will return big number for $c6
|
|
|
|
if ($c6 == "18446743740376218283") {
|
|
|
|
$c6 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$c8 = 4567;// change this to test how mysqli/mysqlnd handles is_ref changing
|
|
|
|
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8);
|
2003-02-12 08:46:29 +08:00
|
|
|
|
|
|
|
var_dump($test);
|
|
|
|
|
|
|
|
mysqli_stmt_close($stmt);
|
2005-11-08 22:43:49 +08:00
|
|
|
|
2007-10-10 18:06:53 +08:00
|
|
|
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch_uint"))
|
|
|
|
printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
|
|
|
$rc = mysqli_query($link, "CREATE TABLE test_bind_fetch_uint(c1 integer unsigned, c2 integer unsigned) ENGINE=" . $engine);
|
|
|
|
if (!$rc)
|
|
|
|
printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
2005-11-08 22:43:49 +08:00
|
|
|
|
2007-10-10 18:06:53 +08:00
|
|
|
if (!mysqli_query($link, "INSERT INTO test_bind_fetch_uint (c1,c2) VALUES (20123456, 3123456789)"))
|
|
|
|
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
2005-11-08 22:43:49 +08:00
|
|
|
|
|
|
|
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_uint");
|
2010-09-23 22:59:13 +08:00
|
|
|
mysqli_stmt_bind_result($stmt, $c1, $c2);
|
|
|
|
mysqli_stmt_execute($stmt);
|
|
|
|
$rc = mysqli_stmt_fetch($stmt);
|
2005-11-08 22:43:49 +08:00
|
|
|
|
|
|
|
echo $c1, "\n", $c2, "\n";
|
|
|
|
|
|
|
|
mysqli_stmt_close($stmt);
|
2008-01-08 20:49:42 +08:00
|
|
|
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
|
|
|
|
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch_uint");
|
2003-02-12 08:46:29 +08:00
|
|
|
mysqli_close($link);
|
2007-10-10 18:06:53 +08:00
|
|
|
print "done!";
|
2003-02-12 08:46:29 +08:00
|
|
|
?>
|
2009-07-06 22:39:10 +08:00
|
|
|
--CLEAN--
|
|
|
|
<?php
|
2009-10-20 04:07:25 +08:00
|
|
|
require_once("connect.inc");
|
2009-09-24 20:51:03 +08:00
|
|
|
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
|
2009-07-06 22:39:10 +08:00
|
|
|
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
|
|
|
|
|
|
|
|
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
|
|
|
|
printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
2005-11-08 22:43:49 +08:00
|
|
|
|
2009-07-06 22:39:10 +08:00
|
|
|
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch_uint"))
|
|
|
|
printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
|
|
|
|
|
|
|
mysqli_close($link);
|
|
|
|
?>
|
2007-10-10 18:06:53 +08:00
|
|
|
--EXPECTF--
|
|
|
|
array(8) {
|
2003-02-12 08:46:29 +08:00
|
|
|
[0]=>
|
|
|
|
int(5)
|
|
|
|
[1]=>
|
|
|
|
int(-23)
|
|
|
|
[2]=>
|
|
|
|
int(4)
|
|
|
|
[3]=>
|
2009-05-28 22:33:43 +08:00
|
|
|
%unicode|string%(14) "33333333333333"
|
2003-02-12 08:46:29 +08:00
|
|
|
[4]=>
|
|
|
|
int(0)
|
|
|
|
[5]=>
|
2005-11-25 09:13:56 +08:00
|
|
|
int(0)
|
2003-02-12 08:46:29 +08:00
|
|
|
[6]=>
|
|
|
|
int(100)
|
2007-10-10 18:06:53 +08:00
|
|
|
[7]=>
|
|
|
|
int(4567)
|
|
|
|
}
|
|
|
|
20123456
|
|
|
|
3123456789
|
2009-05-28 22:33:43 +08:00
|
|
|
done!
|