1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/mysqli: Work on making tests parallizable (#11814)

Batch 1 of amending tests, so they can run in parallel.

Co-authored-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
George Peter Banyard
2023-09-29 18:57:30 +01:00
committed by GitHub
parent 7200bc23a0
commit 6a4031b8c4
98 changed files with 2704 additions and 3104 deletions

View File

@@ -2,13 +2,16 @@
mysqli connect
--EXTENSIONS--
mysqli
--CONFLICTS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
// TODO Not conflicting with parallel?
require_once("connect.inc");
$test = "";

View File

@@ -1,86 +0,0 @@
--TEST--
mysqli bind_result 1
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null"))
printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link,"CREATE TABLE test_fetch_null(col1 tinyint, col2 smallint,
col3 int, col4 bigint,
col5 float, col6 double,
col7 date, col8 time,
col9 varbinary(10),
col10 varchar(50),
col11 char(20)) ENGINE=" . $engine);
if (!$rc)
printf("[003] Cannot create table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link, "INSERT INTO test_fetch_null(col1,col10, col11) VALUES(1,'foo1', 1000),(2,'foo2', 88),(3,'foo3', 389789)");
if (!$rc)
printf("[004] Cannot insert records, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$stmt = mysqli_prepare($link, "SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 from test_fetch_null ORDER BY col1");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11);
var_dump($test);
mysqli_stmt_close($stmt);
@mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(11) {
[0]=>
int(1)
[1]=>
NULL
[2]=>
NULL
[3]=>
NULL
[4]=>
NULL
[5]=>
NULL
[6]=>
NULL
[7]=>
NULL
[8]=>
NULL
[9]=>
string(4) "foo1"
[10]=>
string(4) "1000"
}
done!

View File

@@ -1,104 +0,0 @@
--TEST--
mysqli connect
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_query($link, "SET sql_mode=''");
if (!mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = @mysqli_query($link,"CREATE TABLE test_bind_result(
c1 date,
c2 time,
c3 timestamp(14),
c4 year,
c5 datetime,
c6 timestamp(4),
c7 timestamp(6)) ENGINE=" . $engine);
/*
Seems that not all MySQL 6.0 installations use defaults that ignore the display widths.
From the manual:
From MySQL 4.1.0 on, TIMESTAMP display format differs from that of earlier MySQL releases:
[...]
Display widths (used as described in the preceding section) are no longer supported.
In other words, for declarations such as TIMESTAMP(2), TIMESTAMP(4), and so on,
the display width is ignored.
[...]
*/
if (!$rc)
$rc = @mysqli_query($link,"CREATE TABLE test_bind_result(
c1 date,
c2 time,
c3 timestamp,
c4 year,
c5 datetime,
c6 timestamp,
c7 timestamp) ENGINE=" . $engine);
if (!$rc)
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link, "INSERT INTO test_bind_result VALUES(
'2002-01-02',
'12:49:00',
'2002-01-02 17:46:59',
2010,
'2010-07-10',
'2020','1999-12-29')");
if (!$rc)
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$stmt = mysqli_prepare($link, "SELECT c1, c2, c3, c4, c5, c6, c7 FROM test_bind_result");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(7) {
[0]=>
string(10) "2002-01-02"
[1]=>
string(8) "12:49:00"
[2]=>
string(19) "2002-01-02 17:46:59"
[3]=>
string(4) "2010"
[4]=>
string(19) "2010-07-10 00:00:00"
[5]=>
string(19) "0000-00-00 00:00:00"
[6]=>
string(19) "1999-12-29 00:00:00"
}
done!

View File

@@ -1,90 +0,0 @@
--TEST--
mysqli fetch char/text
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
include 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
if (!mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text) ENGINE=" . $engine))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', 'this is a test0')"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567891', 'this is a test1')"))
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567892', 'this is a test2')"))
printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567893', 'this is a test3')"))
printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch ORDER BY c1"))
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$c1 = $c2 = NULL;
mysqli_stmt_bind_result($stmt, $c1, $c2);
mysqli_stmt_execute($stmt);
$i = 4;
while ($i--) {
mysqli_stmt_fetch($stmt);
$test = array($c1, $c2);
var_dump($test);
}
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(2) {
[0]=>
string(10) "1234567890"
[1]=>
string(15) "this is a test0"
}
array(2) {
[0]=>
string(10) "1234567891"
[1]=>
string(15) "this is a test1"
}
array(2) {
[0]=>
string(10) "1234567892"
[1]=>
string(15) "this is a test2"
}
array(2) {
[0]=>
string(10) "1234567893"
[1]=>
string(15) "this is a test3"
}
done!

View File

@@ -1,62 +0,0 @@
--TEST--
mysqli fetch char/text long
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "CREATE TABLE test_bind_fetch(c1 char(10), c2 text) ENGINE=" . $engine))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$a = str_repeat("A1", 32000);
mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', '$a')");
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_stmt_bind_result($stmt, $c1, $c2);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test[] = $c1;
$test[] = ($a == $c2) ? "32K String ok" : "32K String failed";
var_dump($test);
/* this will crash with libmysql from PHP 5.0.6 (or earlier) to 5.3.0 */
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(2) {
[0]=>
string(10) "1234567890"
[1]=>
string(13) "32K String ok"
}
done!

View File

@@ -1,77 +0,0 @@
--TEST--
mysqli fetch long values
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET sql_mode=''"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned,
c2 int unsigned,
c3 int,
c4 int,
c5 int,
c6 int unsigned,
c7 int) ENGINE=" . $engine);
if (!$rc)
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,35999,NULL,-500,-9999999,-0,0)"))
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(7) {
[0]=>
int(0)
[1]=>
int(35999)
[2]=>
NULL
[3]=>
int(-500)
[4]=>
int(-9999999)
[5]=>
int(0)
[6]=>
int(0)
}
done!

View File

@@ -1,77 +0,0 @@
--TEST--
mysqli fetch short values
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET sql_mode=''"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link, "CREATE TABLE test_bind_fetch(c1 smallint unsigned,
c2 smallint unsigned,
c3 smallint,
c4 smallint,
c5 smallint,
c6 smallint unsigned,
c7 smallint) ENGINE=" . $engine);
if (!$rc)
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,35999,NULL,-500,-9999999,+30,0)"))
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(7) {
[0]=>
int(0)
[1]=>
int(35999)
[2]=>
NULL
[3]=>
int(-500)
[4]=>
int(-32768)
[5]=>
int(30)
[6]=>
int(0)
}
done!

View File

@@ -1,77 +0,0 @@
--TEST--
mysqli fetch tinyint values
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET sql_mode=''"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link, "CREATE TABLE test_bind_fetch(c1 tinyint,
c2 tinyint unsigned,
c3 tinyint not NULL,
c4 tinyint,
c5 tinyint,
c6 tinyint unsigned,
c7 tinyint) ENGINE=" . $engine);
if (!$rc)
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,300,0,-100,-127,+30,0)"))
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(7) {
[0]=>
int(-23)
[1]=>
int(255)
[2]=>
int(0)
[3]=>
int(-100)
[4]=>
int(-127)
[5]=>
int(30)
[6]=>
int(0)
}
done!

View File

@@ -1,117 +0,0 @@
--TEST--
mysqli fetch bigint values (ok to fail with 4.1.x)
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
if (PHP_INT_SIZE == 8) {
echo 'skip test valid only for 32bit systems';
exit;
}
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET sql_mode=''"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$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));
$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));
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
mysqli_stmt_execute($stmt);
$rc = mysqli_stmt_fetch($stmt);
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);
var_dump($test);
mysqli_stmt_close($stmt);
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));
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));
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_uint");
mysqli_stmt_bind_result($stmt, $c1, $c2);
mysqli_stmt_execute($stmt);
$rc = mysqli_stmt_fetch($stmt);
echo $c1, "\n", $c2, "\n";
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch_uint");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
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));
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);
?>
--EXPECT--
array(8) {
[0]=>
int(5)
[1]=>
int(-23)
[2]=>
int(4)
[3]=>
string(14) "33333333333333"
[4]=>
int(0)
[5]=>
int(0)
[6]=>
int(100)
[7]=>
int(4567)
}
20123456
3123456789
done!

View File

@@ -1,80 +0,0 @@
--TEST--
mysqli fetch float values
--INI--
precision=12
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET sql_mode=''"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link, "CREATE TABLE test_bind_fetch(c1 float(3),
c2 float,
c3 float unsigned,
c4 float,
c5 float,
c6 float,
c7 float(10) unsigned) ENGINE=" . $engine);
if (!$rc)
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_query($link, "INSERT INTO test_bind_fetch (c1,c2,c3,c4,c5,c6,c7) VALUES (3.1415926535,-0.000001, -5, 999999999999,
sin(0.6), 1.00000000000001, 888888888888888)");
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(7) {
[0]=>
float(3.14159)
[1]=>
float(-1.0E-6)
[2]=>
float(0)
[3]=>
float(1000000000000)
[4]=>
float(0.564642)
[5]=>
float(1)
[6]=>
float(888889000000000)
}
done!

View File

@@ -1,79 +0,0 @@
--TEST--
mysqli fetch mixed values
--INI--
precision=12
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link, "CREATE TABLE test_bind_result(c1 tinyint, c2 smallint,
c3 int, c4 bigint,
c5 float, c6 double,
c7 varbinary(10),
c8 varchar(50)) ENGINE=" . $engine);
if (!$rc)
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link,"INSERT INTO test_bind_result VALUES(19,2999,3999,4999999,
2345.6,5678.89563,
'foobar','mysql rulez')");
if (!$rc)
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(8) {
[0]=>
int(19)
[1]=>
int(2999)
[2]=>
int(3999)
[3]=>
int(4999999)
[4]=>
float(2345.6)
[5]=>
float(5678.89563)
[6]=>
string(6) "foobar"
[7]=>
string(11) "mysql rulez"
}
done!

View File

@@ -1,78 +0,0 @@
--TEST--
mysqli fetch mixed values 2
--INI--
precision=12
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link, "CREATE TABLE test_bind_result(c1 tinyint, c2 smallint,
c3 int, c4 bigint,
c5 float, c6 double,
c7 varbinary(10),
c8 varchar(10)) ENGINE=" . $engine);
if (!$rc)
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test_bind_result VALUES(120,2999,3999,54,
2.6,58.89,
'206','6.7')"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(8) {
[0]=>
int(120)
[1]=>
int(2999)
[2]=>
int(3999)
[3]=>
int(54)
[4]=>
float(2.6)
[5]=>
float(58.89)
[6]=>
string(3) "206"
[7]=>
string(3) "6.7"
}
done!

View File

@@ -1,70 +0,0 @@
--TEST--
mysqli fetch mixed / mysql_query (may fail when using 4.1 library with 5.x server)
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link, "CREATE TABLE test_bind_result(c1 tinyint, c2 smallint,
c3 int, c4 bigint,
c5 decimal(4,2), c6 double,
c7 varbinary(10),
c8 varchar(10)) ENGINE=" . $engine);
if (!$rc)
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test_bind_result VALUES(120,2999,3999,54,
2.6,58.89,
'206','6.7')"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
$c = array(0,0,0,0,0,0,0,0);
$b_res= mysqli_stmt_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
$result = mysqli_query($link, "select * from test_bind_result");
$d = mysqli_fetch_row($result);
mysqli_free_result($result);
$test = "";
for ($i=0; $i < count($c); $i++)
$test .= ($c[$i] == $d[$i]) ? "1" : "0";
if ($test == "11111111")
echo "ok\n";
else
echo "error";
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
ok
done!

View File

@@ -1,97 +0,0 @@
--TEST--
mysqli autocommit/commit/rollback
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'connect.inc';
if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
}
if (!have_innodb($link)) {
die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
}
?>
--FILE--
<?php
require_once 'connect.inc';
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_autocommit($link, TRUE))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "CREATE TABLE test(a int, b varchar(10)) engine=InnoDB"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test VALUES (1, 'foobar')"))
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_autocommit($link, FALSE))
printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DELETE FROM test"))
printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test VALUES (2, 'egon')"))
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_rollback($link))
printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$result = mysqli_query($link, "SELECT * FROM test"))
printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
printf("Num_of_rows=%d\n", mysqli_num_rows($result));
if (!$row = mysqli_fetch_row($result))
printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_free_result($result);
var_dump($row);
if (!mysqli_query($link, "DELETE FROM test"))
printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test VALUES (2, 'egon')"))
printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_commit($link))
printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$result = mysqli_query($link, "SELECT * FROM test"))
printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$row = mysqli_fetch_row($result))
printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_free_result($result);
var_dump($row);
mysqli_query($link, "DROP TABLE IF EXISTS test");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'clean_table.inc';
?>
--EXPECT--
Num_of_rows=1
array(2) {
[0]=>
string(1) "1"
[1]=>
string(6) "foobar"
}
array(2) {
[0]=>
string(1) "2"
[1]=>
string(4) "egon"
}
done!

View File

@@ -1,95 +0,0 @@
--TEST--
mysqli autocommit/commit/rollback with innodb
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'connect.inc';
if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
}
if (!have_innodb($link)) {
die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
}
?>
--FILE--
<?php
require_once 'connect.inc';
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!$link)
printf("[001] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_select_db($link, $db))
printf("[002] Cannot select DB '%s', [%d] %s\n", $db,
mysqli_errno($link), mysqli_error($link));
if (!mysqli_autocommit($link, TRUE))
printf("[003] Cannot turn on autocommit mode, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link,"DROP TABLE IF EXISTS test") ||
!mysqli_query($link,"CREATE TABLE test(a int, b varchar(10)) Engine=InnoDB") ||
!mysqli_query($link, "INSERT INTO test VALUES (1, 'foobar')"))
printf("[004] Cannot create test data, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
if (!mysqli_autocommit($link, FALSE))
printf("[005] Cannot turn off autocommit mode, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DELETE FROM test") ||
!mysqli_query($link, "INSERT INTO test VALUES (2, 'egon')"))
printf("[006] Cannot modify test data, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
if (!mysqli_rollback($link))
printf("[007] Cannot call rollback, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
$result = mysqli_query($link, "SELECT SQL_NO_CACHE * FROM test");
if (!$result)
printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
var_dump($row);
if (!mysqli_query($link, "DELETE FROM test") ||
!mysqli_query($link, "INSERT INTO test VALUES (2, 'egon')"))
printf("[009] Cannot modify test data, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
mysqli_commit($link);
$result = mysqli_query($link, "SELECT * FROM test");
if (!$result)
printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
var_dump($row);
mysqli_query($link, "DROP TABLE IF EXISTS test");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'clean_table.inc';
?>
--EXPECT--
array(2) {
[0]=>
string(1) "1"
[1]=>
string(6) "foobar"
}
array(2) {
[0]=>
string(1) "2"
[1]=>
string(4) "egon"
}
done!

View File

@@ -1,34 +0,0 @@
--TEST--
mysqli fetch user variable
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET @dummy='foobar'"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$stmt = mysqli_prepare($link, "SELECT @dummy"))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_stmt_bind_result($stmt, $dummy);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
var_dump($dummy);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--EXPECT--
string(6) "foobar"
done!

View File

@@ -1,34 +0,0 @@
--TEST--
mysqli fetch system variables
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "SET AUTOCOMMIT=0"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$stmt = mysqli_prepare($link, "SELECT @@autocommit"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_stmt_bind_result($stmt, $c0);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
var_dump($c0);
mysqli_close($link);
print "done!";
?>
--EXPECT--
int(0)
done!

View File

@@ -1,95 +0,0 @@
--TEST--
mysqli fetch (bind_param + bind_result)
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($link, "DROP TABLE IF EXISTS insert_read"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link,"CREATE TABLE insert_read(col1 tinyint, col2 smallint,
col3 int, col4 bigint,
col5 float, col6 double,
col7 date, col8 time,
col9 varbinary(10),
col10 varchar(50),
col11 char(20)) ENGINE=" . $engine);
if (!$rc)
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$stmt = mysqli_prepare($link, "INSERT INTO insert_read(col1,col10, col11, col6) VALUES (?,?,?,?)"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_stmt_bind_param($stmt, "issd", $c1, $c2, $c3, $c4);
$c1 = 1;
$c2 = "foo";
$c3 = "foobar";
$c4 = 3.14;
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
if (!$stmt = mysqli_prepare($link, "SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 FROM insert_read"))
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS insert_read");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS insert_read"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(11) {
[0]=>
int(1)
[1]=>
NULL
[2]=>
NULL
[3]=>
NULL
[4]=>
NULL
[5]=>
float(3.14)
[6]=>
NULL
[7]=>
NULL
[8]=>
NULL
[9]=>
string(3) "foo"
[10]=>
string(6) "foobar"
}
done!

View File

@@ -1,99 +0,0 @@
--TEST--
mysqli bind_param/bind_result date
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result");
$rc = @mysqli_query($link,"CREATE TABLE test_bind_result(
c1 date,
c2 time,
c3 timestamp(14),
c4 year,
c5 datetime,
c6 timestamp(4),
c7 timestamp(6))");
if (!$rc)
$rc = mysqli_query($link,"CREATE TABLE test_bind_result(
c1 date,
c2 time,
c3 timestamp,
c4 year,
c5 datetime,
c6 timestamp,
c7 timestamp)");
$stmt = mysqli_prepare($link, "INSERT INTO test_bind_result VALUES (?,?,?,?,?,?,?)");
mysqli_stmt_bind_param($stmt, "sssssss", $d1, $d2, $d3, $d4, $d5, $d6, $d7);
$d1 = "2002-01-02";
$d2 = "12:49:00";
$d3 = "2002-01-02 17:46:59";
$d4 = "2010";
$d5 = "2010-07-10";
$d6 = "2020";
$d7 = "1999-12-29";
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($link, "SELECT c1, c2, c3, c4, c5, c6, c7 FROM test_bind_result");
mysqli_stmt_bind_result($stmt,$c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECTF--
array(7) {
[0]=>
%s(10) "2002-01-02"
[1]=>
%s(8) "12:49:00"
[2]=>
%s(19) "2002-01-02 17:46:59"
[3]=>
string(4) "2010"
[4]=>
%s(19) "2010-07-10 00:00:00"
[5]=>
%s(19) "0000-00-00 00:00:00"
[6]=>
%s(19) "1999-12-29 00:00:00"
}
done!

View File

@@ -1,60 +0,0 @@
--TEST--
mysqli bind_param+bind_result char/text
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
mysqli_stmt_bind_param($stmt, "ss", $q1, $q2);
$q1 = "1234567890";
$q2 = "this is a test";
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_stmt_bind_result($stmt, $c1, $c2);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(2) {
[0]=>
string(10) "1234567890"
[1]=>
string(14) "this is a test"
}
done!

View File

@@ -1,65 +0,0 @@
--TEST--
mysqli bind_param/bind_result char/text long
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
mysqli_stmt_bind_param($stmt, "ss", $a1, $a2);
$a1 = "1234567890";
$a2 = str_repeat("A1", 32000);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_stmt_bind_result($stmt, $c1, $c2);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test[] = $c1;
$test[] = ($a2 == $c2) ? "32K String ok" : "32K String failed";
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECTF--
array(2) {
[0]=>
string(10) "1234567890"
[1]=>
%s(13) "32K String ok"
}
done!

View File

@@ -1,84 +0,0 @@
--TEST--
mysqli bind_param/bind_prepare fetch long values
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned,
c2 int unsigned,
c3 int,
c4 int,
c5 int,
c6 int unsigned,
c7 int)");
$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)");
mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
$c1 = -23;
$c2 = 35999;
$c3 = NULL;
$c4 = -500;
$c5 = -9999999;
$c6 = -0;
$c7 = 0;
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(7) {
[0]=>
int(0)
[1]=>
int(35999)
[2]=>
NULL
[3]=>
int(-500)
[4]=>
int(-9999999)
[5]=>
int(0)
[6]=>
int(0)
}
done!

View File

@@ -1,84 +0,0 @@
--TEST--
mysqli bind_param/bind_result short values
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,
c2 smallint unsigned,
c3 smallint,
c4 smallint,
c5 smallint,
c6 smallint unsigned,
c7 smallint)");
$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)");
mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
$c1 = -23;
$c2 = 35999;
$c3 = NULL;
$c4 = -500;
$c5 = -9999999;
$c6 = -0;
$c7 = 0;
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(7) {
[0]=>
int(0)
[1]=>
int(35999)
[2]=>
NULL
[3]=>
int(-500)
[4]=>
int(-32768)
[5]=>
int(0)
[6]=>
int(0)
}
done!

View File

@@ -1,89 +0,0 @@
--TEST--
mysqli bind_param/bind_result tinyint values
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint,
c2 tinyint unsigned,
c3 tinyint not NULL,
c4 tinyint,
c5 tinyint,
c6 tinyint unsigned,
c7 tinyint)");
$stmt = mysqli_prepare ($link, "INSERT INTO test_bind_fetch VALUES(?,?,?,?,?,?,?)");
mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
$c1 = -23;
$c2 = 300;
$c3 = 0;
$c4 = -100;
$c5 = -127;
$c6 = 30;
$c7 = 0;
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,300,0,-100,-127,+30,0)");
$c1 = $c2 = $c3 = $c4 = $c5 = $c6 = $c7 = NULL;
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(7) {
[0]=>
int(-23)
[1]=>
int(255)
[2]=>
int(0)
[3]=>
int(-100)
[4]=>
int(-127)
[5]=>
int(30)
[6]=>
int(0)
}
done!

View File

@@ -1,66 +0,0 @@
--TEST--
mysqli bind_param/bind_result with send_long_data
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 varchar(10), c2 text)");
$stmt = mysqli_prepare ($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
mysqli_stmt_bind_param($stmt, "sb", $c1, $c2);
$c1 = "Hello World";
mysqli_stmt_send_long_data($stmt, 1, "This is the first sentence.");
mysqli_stmt_send_long_data($stmt, 1, " And this is the second sentence.");
mysqli_stmt_send_long_data($stmt, 1, " And finally this is the last sentence.");
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
mysqli_stmt_bind_result($stmt, $d1, $d2);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($d1,$d2);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(2) {
[0]=>
string(10) "Hello Worl"
[1]=>
string(99) "This is the first sentence. And this is the second sentence. And finally this is the last sentence."
}
done!

View File

@@ -1,25 +0,0 @@
--TEST--
function test: mysqli_character_set_name
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$cset = substr(mysqli_character_set_name($link),0,6);
var_dump($cset);
mysqli_close($link);
print "done!";
?>
--EXPECTF--
string(%d) "%s"
done!

View File

@@ -1,43 +0,0 @@
--TEST--
function test: mysqli_affected_rows
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "DROP TABLE IF EXISTS general_test");
mysqli_query($link, "CREATE TABLE general_test (a INT)");
mysqli_query($link, "INSERT INTO general_test VALUES (1),(2),(3)");
$afc = mysqli_affected_rows($link);
var_dump($afc);
mysqli_query($link, "DROP TABLE IF EXISTS general_test");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS general_test"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
int(3)
done!

View File

@@ -1,31 +0,0 @@
--TEST--
function test: mysqli_errno
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$errno = mysqli_errno($link);
var_dump($errno);
mysqli_select_db($link, $db);
mysqli_query($link, "SELECT * FROM non_exisiting_table");
$errno = mysqli_errno($link);
var_dump($errno);
mysqli_close($link);
print "done!";
?>
--EXPECT--
int(0)
int(1146)
done!

View File

@@ -1,31 +0,0 @@
--TEST--
function test: mysqli_error
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$error = mysqli_error($link);
var_dump($error);
mysqli_select_db($link, $db);
mysqli_query($link, "SELECT * FROM non_exisiting_table");
$error = mysqli_error($link);
var_dump($error);
mysqli_close($link);
print "done!";
?>
--EXPECTF--
string(0) ""
string(%d) "%s"
done!

View File

@@ -1,43 +0,0 @@
--TEST--
function test: mysqli_info
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "DROP TABLE IF EXISTS general_test");
mysqli_query($link, "CREATE TABLE general_test (a INT)");
mysqli_query($link, "INSERT INTO general_test VALUES (1),(2),(3)");
$afc = mysqli_info($link);
var_dump($afc);
mysqli_query($link, "DROP TABLE IF EXISTS general_test");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS general_test"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
string(38) "Records: 3 Duplicates: 0 Warnings: 0"
done!

View File

@@ -1,25 +0,0 @@
--TEST--
function test: mysqli_get_server_info
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$sinfo = substr(mysqli_get_server_info($link),0,1);
var_dump(strlen($sinfo));
mysqli_close($link);
print "done!";
?>
--EXPECT--
int(1)
done!

View File

@@ -1,54 +0,0 @@
--TEST--
function test: mysqli_field_count()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "DROP TABLE IF EXISTS test_result");
mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10)) ENGINE = " . $engine);
mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
$ir[] = mysqli_field_count($link);
mysqli_real_query($link, "SELECT * FROM test_result");
$ir[] = mysqli_field_count($link);
var_dump($ir);
mysqli_query($link, "DROP TABLE IF EXISTS test_result");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
array(2) {
[0]=>
int(0)
[1]=>
int(2)
}
done!

View File

@@ -1,48 +0,0 @@
--TEST--
function test: mysqli_num_fields()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "DROP TABLE IF EXISTS test_result");
mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10)) ENGINE = " . $engine);
mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
mysqli_real_query($link, "SELECT * FROM test_result");
if (mysqli_field_count($link)) {
$result = mysqli_store_result($link);
$num = mysqli_num_fields($result);
mysqli_free_result($result);
}
var_dump($num);
mysqli_query($link, "DROP TABLE IF EXISTS test_result");
mysqli_close($link);
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
int(2)

View File

@@ -1,48 +0,0 @@
--TEST--
function test: mysqli_num_rows()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "DROP TABLE IF EXISTS test_result");
mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10)) ENGINE=" . $engine);
mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
mysqli_real_query($link, "SELECT * FROM test_result");
if (mysqli_field_count($link)) {
$result = mysqli_store_result($link);
$num = mysqli_num_rows($result);
mysqli_free_result($result);
}
var_dump($num);
mysqli_query($link, "DROP TABLE IF EXISTS test_result");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
int(1)
done!

View File

@@ -1,39 +0,0 @@
--TEST--
function test: mysqli_warning_count()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_select_db($link, $db);
mysqli_query($link, "DROP TABLE IF EXISTS test_warnings");
mysqli_query($link, "DROP TABLE IF EXISTS test_warnings");
var_dump(mysqli_warning_count($link));
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"))
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
?>
--EXPECT--
int(1)
done!

View File

@@ -1,25 +0,0 @@
--TEST--
non freed statement test
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/************************
* non freed stamement
************************/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$stmt = mysqli_prepare($link, "SELECT CURRENT_USER()");
mysqli_stmt_execute($stmt);
mysqli_close($link);
printf("Ok\n");
?>
--EXPECT--
Ok

View File

@@ -1,26 +0,0 @@
--TEST--
free statement after close
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/************************
* free statement after close
************************/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$stmt1 = mysqli_prepare($link, "SELECT CURRENT_USER()");
mysqli_stmt_execute($stmt1);
mysqli_close($link);
@mysqli_stmt_close($stmt1);
printf("Ok\n");
?>
--EXPECT--
Ok

View File

@@ -1,26 +0,0 @@
--TEST--
call statement after close
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/************************
* statement call after close
************************/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()");
mysqli_close($link);
@mysqli_stmt_execute($stmt2);
@mysqli_stmt_close($stmt2);
printf("Ok\n");
?>
--EXPECT--
Ok

View File

@@ -1,24 +0,0 @@
--TEST--
not freed resultset
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/************************
* non freed resultset
************************/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$result = mysqli_query($link, "SELECT CURRENT_USER()");
mysqli_close($link);
printf("Ok\n");
?>
--EXPECT--
Ok

View File

@@ -1,24 +0,0 @@
--TEST--
free resultset after close
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/************************
* free resultset after close
************************/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$result1 = mysqli_query($link, "SELECT CURRENT_USER()");
mysqli_close($link);
mysqli_free_result($result1);
printf("Ok\n");
?>
--EXPECT--
Ok

View File

@@ -1,23 +0,0 @@
--TEST--
free nothing
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
/************************
* don't free anything
************************/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$result2 = mysqli_query($link, "SELECT CURRENT_USER()");
$stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()");
printf("Ok\n");
?>
--EXPECT--
Ok

View File

@@ -1,11 +0,0 @@
--TEST--
mysqli get_client_info
--EXTENSIONS--
mysqli
--FILE--
<?php
$s = mysqli_get_client_info();
echo gettype($s);
?>
--EXPECT--
string

View File

@@ -0,0 +1,78 @@
--TEST--
mysqli fetch bigint values (ok to fail with 4.1.x)
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
if (PHP_INT_SIZE == 8) {
echo 'skip test valid only for 32bit systems';
exit;
}
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
// To get consistent result without depending on the DB version/setup
mysqli_query($link, "SET sql_mode=''");
mysqli_query(
$link,
"CREATE TABLE test_bind_fetch_integers_big(
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=" . get_default_db_engine()
);
mysqli_query($link, "INSERT INTO test_bind_fetch_integers_big (c2,c3,c4,c5,c6,c7,c8)
VALUES (-23,4.0,33333333333333,0,-333333333333,99.9,1234)");
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_integers_big");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$c8 = 4567;// change this to test how mysqli/mysqlnd handles is_ref changing
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_bind_fetch_integers_big');
?>
--EXPECT--
array(8) {
[0]=>
int(5)
[1]=>
int(-23)
[2]=>
int(4)
[3]=>
string(14) "33333333333333"
[4]=>
int(0)
[5]=>
int(0)
[6]=>
int(100)
[7]=>
int(4567)
}
done!

View File

@@ -0,0 +1,50 @@
--TEST--
mysqli fetch long char/text
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query($link, "CREATE TABLE test_bind_fetch_char_long(c1 char(10), c2 text) ENGINE=" . get_default_db_engine());
$a = str_repeat("A1", 32000);
mysqli_query($link, "INSERT INTO test_bind_fetch_char_long VALUES ('1234567890', '$a')");
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_char_long");
mysqli_stmt_bind_result($stmt, $c1, $c2);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test[] = $c1;
$test[] = ($a == $c2) ? "32K String ok" : "32K String failed";
var_dump($test);
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_bind_fetch_char_long');
?>
--EXPECT--
array(2) {
[0]=>
string(10) "1234567890"
[1]=>
string(13) "32K String ok"
}
done!

View File

@@ -0,0 +1,74 @@
--TEST--
mysqli fetch char/text
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query($link,"CREATE TABLE test_bind_fetch_char(c1 char(10), c2 text) ENGINE=" . get_default_db_engine());
/* Insert test data */
mysqli_query(
$link,
"INSERT INTO test_bind_fetch_char VALUES
('1234567890', 'this is a test0'),
('1234567891', 'this is a test1'),
('1234567892', 'this is a test2'),
('1234567893', 'this is a test3')"
);
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_char ORDER BY c1");
$c1 = $c2 = NULL;
mysqli_stmt_bind_result($stmt, $c1, $c2);
mysqli_stmt_execute($stmt);
$i = 4;
while ($i--) {
mysqli_stmt_fetch($stmt);
$test = array($c1, $c2);
var_dump($test);
}
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_bind_fetch_char');
?>
--EXPECT--
array(2) {
[0]=>
string(10) "1234567890"
[1]=>
string(15) "this is a test0"
}
array(2) {
[0]=>
string(10) "1234567891"
[1]=>
string(15) "this is a test1"
}
array(2) {
[0]=>
string(10) "1234567892"
[1]=>
string(15) "this is a test2"
}
array(2) {
[0]=>
string(10) "1234567893"
[1]=>
string(15) "this is a test3"
}
done!

View File

@@ -0,0 +1,75 @@
--TEST--
mysqli bind_result datetimes
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
// To get consistent result without depending on the DB version/setup
mysqli_query($link, "SET sql_mode=''");
mysqli_query(
$link,
"CREATE TABLE test_bind_result_datetime(
c1 date,
c2 time,
c3 timestamp,
c4 year,
c5 datetime,
c6 timestamp(4),
c7 timestamp(6)
) ENGINE=" . get_default_db_engine()
);
mysqli_query($link, "INSERT INTO test_bind_result_datetime VALUES(
'2002-01-02',
'12:49:00',
'2002-01-02 17:46:59',
2010,
'2010-07-10',
'2020','1999-12-29')");
$stmt = mysqli_prepare($link, "SELECT c1, c2, c3, c4, c5, c6, c7 FROM test_bind_result_datetime");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_bind_result_datetime');
?>
--EXPECT--
array(7) {
[0]=>
string(10) "2002-01-02"
[1]=>
string(8) "12:49:00"
[2]=>
string(19) "2002-01-02 17:46:59"
[3]=>
string(4) "2010"
[4]=>
string(19) "2010-07-10 00:00:00"
[5]=>
string(24) "0000-00-00 00:00:00.0000"
[6]=>
string(26) "1999-12-29 00:00:00.000000"
}
done!

View File

@@ -0,0 +1,73 @@
--TEST--
mysqli fetch float values
--INI--
precision=12
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
// To get consistent result without depending on the DB version/setup
mysqli_query($link, "SET sql_mode=''");
mysqli_query(
$link,
"CREATE TABLE test_bind_fetch_float(
c1 float(3),
c2 float,
c3 float unsigned,
c4 float,
c5 float,
c6 float,
c7 float(10) unsigned
) ENGINE=" . get_default_db_engine()
);
mysqli_query($link, "INSERT INTO test_bind_fetch_float (c1,c2,c3,c4,c5,c6,c7)
VALUES (3.1415926535,-0.000001, -5, 999999999999, sin(0.6), 1.00000000000001, 888888888888888)");
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_float");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_bind_fetch_float');
?>
--EXPECT--
array(7) {
[0]=>
float(3.14159)
[1]=>
float(-1.0E-6)
[2]=>
float(0)
[3]=>
float(1000000000000)
[4]=>
float(0.564642)
[5]=>
float(1)
[6]=>
float(888889000000000)
}
done!

View File

@@ -0,0 +1,60 @@
--TEST--
mysqli binding resulting of a fetch and fetching a row directly produce same results
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query(
$link,
"CREATE TABLE test_bind_fetch_and_row_fetch(
c1 tinyint, c2 smallint,
c3 int, c4 bigint,
c5 decimal(4,2), c6 double,
c7 varbinary(10),
c8 varchar(10)
) ENGINE=" . get_default_db_engine()
);
mysqli_query($link, "INSERT INTO test_bind_fetch_and_row_fetch
VALUES(120,2999,3999,54, 2.6,58.89, '206','6.7')");
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_and_row_fetch");
$c = array(0,0,0,0,0,0,0,0);
mysqli_stmt_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
$result = mysqli_query($link, "SELECT * FROM test_bind_fetch_and_row_fetch");
$d = mysqli_fetch_row($result);
mysqli_free_result($result);
$test = "";
for ($i=0; $i < count($c); $i++)
$test .= ($c[$i] == $d[$i]) ? "1" : "0";
if ($test == "11111111")
echo "ok\n";
else
echo "error";
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_bind_fetch_and_row_fetch');
?>
--EXPECT--
ok
done!

View File

@@ -0,0 +1,69 @@
--TEST--
mysqli fetch integer values
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
// To get consistent result without depending on the DB version/setup
mysqli_query($link, "SET sql_mode=''");
mysqli_query(
$link,
"CREATE TABLE test_bind_fetch_integers(
c1 int unsigned,
c2 int unsigned,
c3 int,
c4 int,
c5 int,
c6 int unsigned,
c7 int
) ENGINE=" . get_default_db_engine()
);
mysqli_query($link, "INSERT INTO test_bind_fetch_integers VALUES (-23,35999,NULL,-500,-9999999,-0,0)");
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_integers");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_bind_fetch_integers');
?>
--EXPECT--
array(7) {
[0]=>
int(0)
[1]=>
int(35999)
[2]=>
NULL
[3]=>
int(-500)
[4]=>
int(-9999999)
[5]=>
int(0)
[6]=>
int(0)
}
done!

View File

@@ -1,20 +1,19 @@
--TEST--
mysqli fetch functions
mysqli fetch MySQL functions
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once 'connect.inc';
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$link = default_mysqli_connect();
if (!$stmt = mysqli_prepare($link, "SELECT md5('bar'), database(), 'foo'"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$stmt = mysqli_prepare($link, "SELECT md5('bar'), database(), 'foo'");
mysqli_stmt_bind_result($stmt, $c0, $c1, $c2);
mysqli_stmt_execute($stmt);
@@ -23,7 +22,7 @@ require_once 'skipifconnectfailure.inc';
mysqli_stmt_close($stmt);
$test = array($c0, $c1, $c2);
if ($c1 !== $db) {
if ($c1 !== get_default_database()) {
echo "Different data\n";
}

View File

@@ -0,0 +1,69 @@
--TEST--
mysqli fetch small/short integer values
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
// To get consistent result without depending on the DB version/setup
mysqli_query($link, "SET sql_mode=''");
mysqli_query(
$link,
"CREATE TABLE test_bind_fetch_integers_small(
c1 smallint unsigned,
c2 smallint unsigned,
c3 smallint,
c4 smallint,
c5 smallint,
c6 smallint unsigned,
c7 smallint
) ENGINE=" . get_default_db_engine()
);
mysqli_query($link, "INSERT INTO test_bind_fetch_integers_small VALUES (-23,35999,NULL,-500,-9999999,+30,0)");
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_integers_small");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_bind_fetch_integers_small');
?>
--EXPECT--
array(7) {
[0]=>
int(0)
[1]=>
int(35999)
[2]=>
NULL
[3]=>
int(-500)
[4]=>
int(-32768)
[5]=>
int(30)
[6]=>
int(0)
}
done!

View File

@@ -0,0 +1,32 @@
--TEST--
mysqli fetch system variables
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query($link, "SET AUTOCOMMIT=0");
$stmt = mysqli_prepare($link, "SELECT @@autocommit");
mysqli_stmt_bind_result($stmt, $c0);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
var_dump($c0);
mysqli_close($link);
print "done!";
?>
--EXPECT--
int(0)
done!

View File

@@ -0,0 +1,69 @@
--TEST--
mysqli fetch tinyint values
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
// To get consistent result without depending on the DB version/setup
mysqli_query($link, "SET sql_mode=''");
mysqli_query(
$link,
"CREATE TABLE test_bind_fetch_integers_tiny(
c1 tinyint,
c2 tinyint unsigned,
c3 tinyint not NULL,
c4 tinyint,
c5 tinyint,
c6 tinyint unsigned,
c7 tinyint
) ENGINE=" . get_default_db_engine()
);
mysqli_query($link, "INSERT INTO test_bind_fetch_integers_tiny VALUES (-23,300,0,-100,-127,+30,0)");
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_integers_tiny");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_bind_fetch_integers_tiny');
?>
--EXPECT--
array(7) {
[0]=>
int(-23)
[1]=>
int(255)
[2]=>
int(0)
[3]=>
int(-100)
[4]=>
int(-127)
[5]=>
int(30)
[6]=>
int(0)
}
done!

View File

@@ -0,0 +1,42 @@
--TEST--
mysqli fetch unsigned integer values
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
// To get consistent result without depending on the DB version/setup
mysqli_query($link, "SET sql_mode=''");
mysqli_query($link, "CREATE TABLE test_bind_fetch_uint(c1 integer unsigned, c2 integer unsigned) ENGINE=" . get_default_db_engine());
mysqli_query($link, "INSERT INTO test_bind_fetch_uint (c1,c2) VALUES (20123456, 3123456789)");
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_uint");
mysqli_stmt_bind_result($stmt, $c1, $c2);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
echo $c1, "\n", $c2, "\n";
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_bind_fetch_uint');
?>
--EXPECT--
20123456
3123456789
done!

View File

@@ -0,0 +1,32 @@
--TEST--
mysqli fetch user variable
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query($link, "SET @dummy='foobar'");
$stmt = mysqli_prepare($link, "SELECT @dummy");
mysqli_stmt_bind_result($stmt, $dummy);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
var_dump($dummy);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--EXPECT--
string(6) "foobar"
done!

View File

@@ -0,0 +1,79 @@
--TEST--
mysqli bind_result 1
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query(
$link,
"CREATE TABLE test_bind_fetch_varied(
col1 tinyint, col2 smallint,
col3 int, col4 bigint,
col5 float, col6 double,
col7 date, col8 time,
col9 varbinary(10),
col10 varchar(50),
col11 char(20),
col12 char(3) DEFAULT NULL
) ENGINE=" . get_default_db_engine()
);
mysqli_query($link, "INSERT INTO test_bind_fetch_varied
VALUES(1, 2, 3, 4, 5.1, 6.2, '2020-02-21', '11:04', '111', 'foo1', 1000, null)");
$stmt = mysqli_prepare($link, "SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11, col12 from test_bind_fetch_varied ORDER BY col1");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11, $c12);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11,$c12);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_bind_fetch_varied');
?>
--EXPECT--
array(12) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
[4]=>
float(5.1)
[5]=>
float(6.2)
[6]=>
string(10) "2020-02-21"
[7]=>
string(8) "11:04:00"
[8]=>
string(3) "111"
[9]=>
string(4) "foo1"
[10]=>
string(4) "1000"
[11]=>
NULL
}
done!

View File

@@ -0,0 +1,55 @@
--TEST--
mysqli insert (bind_param + bind_result) long char/text types
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query($link,"CREATE TABLE insert_bind_char_text_long(c1 char(10), c2 text)");
$stmt = mysqli_prepare($link, "INSERT INTO insert_bind_char_text_long VALUES (?,?)");
mysqli_stmt_bind_param($stmt, "ss", $a1, $a2);
$a1 = "1234567890";
$a2 = str_repeat("A1", 32000);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($link, "SELECT * FROM insert_bind_char_text_long");
mysqli_stmt_bind_result($stmt, $c1, $c2);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test[] = $c1;
$test[] = ($a2 == $c2) ? "32K String ok" : "32K String failed";
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('insert_bind_char_text_long');
?>
--EXPECTF--
array(2) {
[0]=>
string(10) "1234567890"
[1]=>
%s(13) "32K String ok"
}
done!

View File

@@ -0,0 +1,50 @@
--TEST--
mysqli insert (bind_param + bind_result) char/text types
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query($link,"CREATE TABLE insert_bind_char_text(c1 char(10), c2 text)");
$stmt = mysqli_prepare($link, "INSERT INTO insert_bind_char_text VALUES (?,?)");
mysqli_stmt_bind_param($stmt, "ss", $q1, $q2);
$q1 = "1234567890";
$q2 = "this is a test";
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($link, "SELECT * FROM insert_bind_char_text");
mysqli_stmt_bind_result($stmt, $c1, $c2);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('insert_bind_char_text');
?>
--EXPECT--
array(2) {
[0]=>
string(10) "1234567890"
[1]=>
string(14) "this is a test"
}
done!

View File

@@ -0,0 +1,85 @@
--TEST--
mysqli insert (bind_param + bind_result) datetime types
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
// To get consistent result without depending on the DB version/setup
mysqli_query($link, "SET sql_mode=''");
/* 14 Too big precision for timestamp */
mysqli_query(
$link,
"CREATE TABLE insert_bind_datetime(
c1 date,
c2 time,
c3 timestamp,
c4 year,
c5 datetime,
c6 timestamp,
c7 timestamp
)"
);
$stmt = mysqli_prepare($link, "INSERT INTO insert_bind_datetime VALUES (?,?,?,?,?,?,?)");
mysqli_stmt_bind_param($stmt, "sssssss", $d1, $d2, $d3, $d4, $d5, $d6, $d7);
$d1 = "2002-01-02";
$d2 = "12:49:00";
$d3 = "2002-01-02 17:46:59";
$d4 = "2010";
$d5 = "2010-07-10";
$d6 = "2020";
$d7 = "1999-12-29";
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($link, "SELECT c1, c2, c3, c4, c5, c6, c7 FROM insert_bind_datetime");
mysqli_stmt_bind_result($stmt,$c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('insert_bind_datetime');
?>
--EXPECTF--
array(7) {
[0]=>
%s(10) "2002-01-02"
[1]=>
%s(8) "12:49:00"
[2]=>
%s(19) "2002-01-02 17:46:59"
[3]=>
string(4) "2010"
[4]=>
%s(19) "2010-07-10 00:00:00"
[5]=>
%s(19) "0000-00-00 00:00:00"
[6]=>
%s(19) "1999-12-29 00:00:00"
}
done!

View File

@@ -0,0 +1,81 @@
--TEST--
mysqli insert (bind_param + bind_result) integer types
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
// To get consistent result without depending on the DB version/setup
mysqli_query($link, "SET sql_mode=''");
mysqli_query(
$link,
"CREATE TABLE insert_bind_integers(
c1 int unsigned,
c2 int unsigned,
c3 int,
c4 int,
c5 int,
c6 int unsigned,
c7 int
)"
);
$stmt = mysqli_prepare($link, "INSERT INTO insert_bind_integers VALUES (?,?,?,?,?,?,?)");
mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
$c1 = -23;
$c2 = 35999;
$c3 = NULL;
$c4 = -500;
$c5 = -9999999;
$c6 = -0;
$c7 = 0;
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($link, "SELECT * FROM insert_bind_integers");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('insert_bind_integers');
?>
--EXPECT--
array(7) {
[0]=>
int(0)
[1]=>
int(35999)
[2]=>
NULL
[3]=>
int(-500)
[4]=>
int(-9999999)
[5]=>
int(0)
[6]=>
int(0)
}
done!

View File

@@ -0,0 +1,58 @@
--TEST--
mysqli insert (bind_param + bind_result) with send_long_data
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
// To get consistent result without depending on the DB version/setup
mysqli_query($link, "SET sql_mode=''");
mysqli_query($link,"CREATE TABLE insert_bind_send_long_data(c1 varchar(10), c2 text)");
$stmt = mysqli_prepare ($link, "INSERT INTO insert_bind_send_long_data VALUES (?,?)");
mysqli_stmt_bind_param($stmt, "sb", $c1, $c2);
$c1 = "Hello World";
mysqli_stmt_send_long_data($stmt, 1, "This is the first sentence.");
mysqli_stmt_send_long_data($stmt, 1, " And this is the second sentence.");
mysqli_stmt_send_long_data($stmt, 1, " And finally this is the last sentence.");
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($link, "SELECT * FROM insert_bind_send_long_data");
mysqli_stmt_bind_result($stmt, $d1, $d2);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($d1,$d2);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('insert_bind_send_long_data');
?>
--EXPECT--
array(2) {
[0]=>
string(10) "Hello Worl"
[1]=>
string(99) "This is the first sentence. And this is the second sentence. And finally this is the last sentence."
}
done!

View File

@@ -0,0 +1,81 @@
--TEST--
mysqli insert (bind_param + bind_result) small integer types
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
// To get consistent result without depending on the DB version/setup
mysqli_query($link, "SET sql_mode=''");
mysqli_query(
$link,
"CREATE TABLE insert_bind_smallint(
c1 smallint unsigned,
c2 smallint unsigned,
c3 smallint,
c4 smallint,
c5 smallint,
c6 smallint unsigned,
c7 smallint
)"
);
$stmt = mysqli_prepare($link, "INSERT INTO insert_bind_smallint VALUES (?,?,?,?,?,?,?)");
mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
$c1 = -23;
$c2 = 35999;
$c3 = NULL;
$c4 = -500;
$c5 = -9999999;
$c6 = -0;
$c7 = 0;
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($link, "SELECT * FROM insert_bind_smallint");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('insert_bind_smallint');
?>
--EXPECT--
array(7) {
[0]=>
int(0)
[1]=>
int(35999)
[2]=>
NULL
[3]=>
int(-500)
[4]=>
int(-32768)
[5]=>
int(0)
[6]=>
int(0)
}
done!

View File

@@ -0,0 +1,83 @@
--TEST--
mysqli insert (bind_param + bind_result) tiny integer types
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query($link, "SET sql_mode=''");
mysqli_query(
$link,
"CREATE TABLE insert_bind_tinyint(
c1 tinyint,
c2 tinyint unsigned,
c3 tinyint not NULL,
c4 tinyint,
c5 tinyint,
c6 tinyint unsigned,
c7 tinyint
)"
);
$stmt = mysqli_prepare ($link, "INSERT INTO insert_bind_tinyint VALUES(?,?,?,?,?,?,?)");
mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
$c1 = -23;
$c2 = 300;
$c3 = 0;
$c4 = -100;
$c5 = -127;
$c6 = 30;
$c7 = 0;
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$c1 = $c2 = $c3 = $c4 = $c5 = $c6 = $c7 = NULL;
$stmt = mysqli_prepare($link, "SELECT * FROM insert_bind_tinyint");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('insert_bind_tinyint');
?>
--EXPECT--
array(7) {
[0]=>
int(-23)
[1]=>
int(255)
[2]=>
int(0)
[3]=>
int(-100)
[4]=>
int(-127)
[5]=>
int(30)
[6]=>
int(0)
}
done!

View File

@@ -0,0 +1,86 @@
--TEST--
mysqli insert (bind_param + bind_result)
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query(
$link,
"CREATE TABLE insert_bind_varied1(
col1 tinyint, col2 smallint,
col3 int, col4 bigint,
col5 float, col6 double,
col7 date, col8 time,
col9 varbinary(10),
col10 varchar(50),
col11 char(20)
) ENGINE=" . get_default_db_engine()
);
$stmt = mysqli_prepare($link, "INSERT INTO insert_bind_varied1(col1,col10, col11, col6) VALUES (?,?,?,?)");
mysqli_stmt_bind_param($stmt, "issd", $c1, $c2, $c3, $c4);
$c1 = 1;
$c2 = "foo";
$c3 = "foobar";
$c4 = 3.14;
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$stmt = mysqli_prepare($link, "SELECT * FROM insert_bind_varied1");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11);
var_dump($test);
mysqli_stmt_close($stmt);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('insert_bind_varied1');
?>
--EXPECT--
array(11) {
[0]=>
int(1)
[1]=>
NULL
[2]=>
NULL
[3]=>
NULL
[4]=>
NULL
[5]=>
float(3.14)
[6]=>
NULL
[7]=>
NULL
[8]=>
NULL
[9]=>
string(3) "foo"
[10]=>
string(6) "foobar"
}
done!

View File

@@ -0,0 +1,29 @@
--TEST--
mysqli_stmt_execute() after mysqli_close()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
$stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()");
mysqli_close($link);
try {
mysqli_stmt_execute($stmt2);
} catch (mysqli_sql_exception $e) {
echo $e->getMessage(), PHP_EOL;
}
mysqli_stmt_close($stmt2);
printf("Ok\n");
?>
--EXPECT--
MySQL server has gone away
Ok

View File

@@ -0,0 +1,21 @@
--TEST--
free nothing (e.g. no mysqli_close())
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
$result2 = mysqli_query($link, "SELECT CURRENT_USER()");
$stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()");
printf("Ok\n");
?>
--EXPECT--
Ok

View File

@@ -0,0 +1,22 @@
--TEST--
free resultset (mysqli_free_result()) after mysqli_close()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
$result1 = mysqli_query($link, "SELECT CURRENT_USER()");
mysqli_close($link);
mysqli_free_result($result1);
printf("Ok\n");
?>
--EXPECT--
Ok

View File

@@ -0,0 +1,24 @@
--TEST--
free statement (mysqli_stmt_close()) after mysqli_close()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
$stmt1 = mysqli_prepare($link, "SELECT CURRENT_USER()");
mysqli_stmt_execute($stmt1);
mysqli_close($link);
mysqli_stmt_close($stmt1);
printf("Ok\n");
?>
--EXPECT--
Ok

View File

@@ -0,0 +1,22 @@
--TEST--
not freed resultset (missing mysqli_free_result())
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
$result = mysqli_query($link, "SELECT CURRENT_USER()");
mysqli_close($link);
printf("Ok\n");
?>
--EXPECT--
Ok

View File

@@ -0,0 +1,23 @@
--TEST--
non freed statement (missing mysqli_stmt_close())
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
$stmt = mysqli_prepare($link, "SELECT CURRENT_USER()");
mysqli_stmt_execute($stmt);
mysqli_close($link);
printf("Ok\n");
?>
--EXPECT--
Ok

View File

@@ -0,0 +1,174 @@
--TEST--
mysqli_fetch_all()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = setup_table_with_data_on_default_connection('test_mysqli_fetch_all');
$result = mysqli_query($link, "SELECT * FROM test_mysqli_fetch_all ORDER BY id LIMIT 2");
echo "Default mode\n";
var_dump(mysqli_fetch_all($result));
mysqli_free_result($result);
$result = mysqli_query($link, "SELECT * FROM test_mysqli_fetch_all ORDER BY id LIMIT 2");
print "Mode: MYSQLI_NUM\n";
var_dump(mysqli_fetch_all($result, MYSQLI_NUM));
mysqli_free_result($result);
$result = mysqli_query($link, "SELECT * FROM test_mysqli_fetch_all ORDER BY id LIMIT 2");
print "Mode: MYSQLI_BOTH\n";
var_dump(mysqli_fetch_all($result, MYSQLI_BOTH));
mysqli_free_result($result);
$result = mysqli_query($link, "SELECT * FROM test_mysqli_fetch_all ORDER BY id LIMIT 2");
print "Mode: MYSQLI_ASSOC\n";
var_dump(mysqli_fetch_all($result, MYSQLI_ASSOC));
echo "mysqli_fetch_all() after fetching\n";
var_dump(mysqli_fetch_all($result));
mysqli_free_result($result);
$result = mysqli_query($link, "SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e");
print "[017]\n";
var_dump(mysqli_fetch_all($result, MYSQLI_BOTH));
// Illegal mode
try {
mysqli_fetch_all($result, -10);
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
mysqli_free_result($result);
try {
mysqli_fetch_array($result, MYSQLI_ASSOC);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_mysqli_fetch_all');
?>
--EXPECT--
Default mode
array(2) {
[0]=>
array(2) {
[0]=>
string(1) "1"
[1]=>
string(1) "a"
}
[1]=>
array(2) {
[0]=>
string(1) "2"
[1]=>
string(1) "b"
}
}
Mode: MYSQLI_NUM
array(2) {
[0]=>
array(2) {
[0]=>
string(1) "1"
[1]=>
string(1) "a"
}
[1]=>
array(2) {
[0]=>
string(1) "2"
[1]=>
string(1) "b"
}
}
Mode: MYSQLI_BOTH
array(2) {
[0]=>
array(4) {
[0]=>
string(1) "1"
["id"]=>
string(1) "1"
[1]=>
string(1) "a"
["label"]=>
string(1) "a"
}
[1]=>
array(4) {
[0]=>
string(1) "2"
["id"]=>
string(1) "2"
[1]=>
string(1) "b"
["label"]=>
string(1) "b"
}
}
Mode: MYSQLI_ASSOC
array(2) {
[0]=>
array(2) {
["id"]=>
string(1) "1"
["label"]=>
string(1) "a"
}
[1]=>
array(2) {
["id"]=>
string(1) "2"
["label"]=>
string(1) "b"
}
}
mysqli_fetch_all() after fetching
array(0) {
}
[017]
array(1) {
[0]=>
array(11) {
[0]=>
string(1) "1"
["a"]=>
string(1) "2"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
["c"]=>
string(1) "3"
[3]=>
string(1) "4"
["C"]=>
string(1) "4"
[4]=>
NULL
["d"]=>
NULL
[5]=>
string(1) "1"
["e"]=>
string(1) "1"
}
}
mysqli_fetch_all(): Argument #2 ($mode) must be one of MYSQLI_NUM, MYSQLI_ASSOC, or MYSQLI_BOTH
mysqli_result object is already closed
done!

View File

@@ -0,0 +1,231 @@
--TEST--
mysqli_fetch_all() data types variation
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
function func_mysqli_fetch_all(
mysqli $link,
string $engine,
string $sql_type,
string|int|null $sql_value,
mixed $php_value,
$offset,
$regexp_comparison = NULL
) {
try {
mysqli_query($link, $sql = sprintf("CREATE TABLE test_mysqli_fetch_all_data_types_variation(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine));
} catch (mysqli_sql_exception $e) {
// don't bail, engine might not support the datatype
echo $e->getMessage(), PHP_EOL;
return;
}
if (is_null($php_value)) {
mysqli_query($link, $sql = sprintf("INSERT INTO test_mysqli_fetch_all_data_types_variation(id, label) VALUES (1, NULL)"));
} else {
if (is_string($sql_value)) {
mysqli_query($link, $sql = "INSERT INTO test_mysqli_fetch_all_data_types_variation(id, label) VALUES (1, '" . $sql_value . "')");
} else {
mysqli_query($link, $sql = sprintf("INSERT INTO test_mysqli_fetch_all_data_types_variation(id, label) VALUES (1, '%d')", $sql_value));
}
}
$result = mysqli_query($link, "SELECT id, label FROM test_mysqli_fetch_all_data_types_variation");
$tmp = mysqli_fetch_all($result, MYSQLI_BOTH);
$row = $tmp[0];
$fields = mysqli_fetch_fields($result);
if ($regexp_comparison) {
if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) {
printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,
gettype($php_value), $php_value, $regexp_comparison,
gettype($row[1]), $row[1],
gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link));
}
} else {
if (($row['label'] !== $php_value) || ($row[1] != $php_value)) {
printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,
gettype($php_value), $php_value,
gettype($row[1]), $row[1],
gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link));
}
}
mysqli_query($link, 'DROP TABLE test_mysqli_fetch_all_data_types_variation');
}
// TODO Optimize this?
function func_mysqli_fetch_array_make_string(int $len): string {
$ret = '';
for ($i = 0; $i < $len; $i++) {
$ret .= chr(mt_rand(65, 90));
}
return $ret;
}
$engine = get_default_db_engine();
func_mysqli_fetch_all($link, $engine, "TINYINT", -11, "-11", 20);
func_mysqli_fetch_all($link, $engine, "TINYINT", NULL, NULL, 30);
func_mysqli_fetch_all($link, $engine, "TINYINT UNSIGNED", 1, "1", 40);
func_mysqli_fetch_all($link, $engine, "TINYINT UNSIGNED", NULL, NULL, 50);
func_mysqli_fetch_all($link, $engine, "BOOL", 1, "1", 60);
func_mysqli_fetch_all($link, $engine, "BOOL", NULL, NULL, 70);
func_mysqli_fetch_all($link, $engine, "BOOLEAN", 0, "0", 80);
func_mysqli_fetch_all($link, $engine, "BOOLEAN", NULL, NULL, 90);
func_mysqli_fetch_all($link, $engine, "SMALLINT", -32768, "-32768", 100);
func_mysqli_fetch_all($link, $engine, "SMALLINT", 32767, "32767", 110);
func_mysqli_fetch_all($link, $engine, "SMALLINT", NULL, NULL, 120);
func_mysqli_fetch_all($link, $engine, "SMALLINT UNSIGNED", 65535, "65535", 130);
func_mysqli_fetch_all($link, $engine, "SMALLINT UNSIGNED", NULL, NULL, 140);
func_mysqli_fetch_all($link, $engine, "MEDIUMINT", -8388608, "-8388608", 150);
func_mysqli_fetch_all($link, $engine, "MEDIUMINT", 8388607, "8388607", 160);
func_mysqli_fetch_all($link, $engine, "MEDIUMINT", NULL, NULL, 170);
func_mysqli_fetch_all($link, $engine, "MEDIUMINT UNSIGNED", 16777215, "16777215", 180);
func_mysqli_fetch_all($link, $engine, "MEDIUMINT UNSIGNED", NULL, NULL, 190);
func_mysqli_fetch_all($link, $engine, "INTEGER", -2147483648, "-2147483648", 200);
func_mysqli_fetch_all($link, $engine, "INTEGER", 2147483647, "2147483647", 210);
func_mysqli_fetch_all($link, $engine, "INTEGER", NULL, NULL, 220);
func_mysqli_fetch_all($link, $engine, "INTEGER UNSIGNED", "4294967295", "4294967295", 230);
func_mysqli_fetch_all($link, $engine, "INTEGER UNSIGNED", NULL, NULL, 240);
func_mysqli_fetch_all($link, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250);
func_mysqli_fetch_all($link, $engine, "BIGINT", NULL, NULL, 260);
func_mysqli_fetch_all($link, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 270);
func_mysqli_fetch_all($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280);
func_mysqli_fetch_all($link, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu");
func_mysqli_fetch_all($link, $engine, "FLOAT", NULL, NULL, 300);
func_mysqli_fetch_all($link, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+19", 310, "/1\.84467e\+?[0]?19/iu");
func_mysqli_fetch_all($link, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320);
func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330);
func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2)", NULL, NULL, 340);
func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350);
func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360);
func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370);
func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", NULL, NULL, 380);
func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390);
func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400);
// don't care about date() strict TZ warnings...
func_mysqli_fetch_all($link, $engine, "DATE", @date('Y-m-d'), @date('Y-m-d'), 410);
func_mysqli_fetch_all($link, $engine, "DATE NOT NULL", @date('Y-m-d'), @date('Y-m-d'), 420);
func_mysqli_fetch_all($link, $engine, "DATE", NULL, NULL, 430);
func_mysqli_fetch_all($link, $engine, "DATETIME", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 440);
func_mysqli_fetch_all($link, $engine, "DATETIME NOT NULL", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 450);
func_mysqli_fetch_all($link, $engine, "DATETIME", NULL, NULL, 460);
func_mysqli_fetch_all($link, $engine, "TIMESTAMP", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 470);
func_mysqli_fetch_all($link, $engine, "TIME", @date('H:i:s'), @date('H:i:s'), 480);
func_mysqli_fetch_all($link, $engine, "TIME NOT NULL", @date('H:i:s'), @date('H:i:s'), 490);
func_mysqli_fetch_all($link, $engine, "TIME", NULL, NULL, 500);
func_mysqli_fetch_all($link, $engine, "YEAR", @date('Y'), @date('Y'), 510);
func_mysqli_fetch_all($link, $engine, "YEAR NOT NULL", @date('Y'), @date('Y'), 520);
func_mysqli_fetch_all($link, $engine, "YEAR", NULL, NULL, 530);
$string255 = func_mysqli_fetch_array_make_string(255);
func_mysqli_fetch_all($link, $engine, "CHAR(1)", "a", "a", 540);
func_mysqli_fetch_all($link, $engine, "CHAR(255)", $string255, $string255, 550);
func_mysqli_fetch_all($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560);
func_mysqli_fetch_all($link, $engine, "CHAR(1)", NULL, NULL, 570);
$string16k = func_mysqli_fetch_array_make_string(16000);
func_mysqli_fetch_all($link, $engine, "VARCHAR(1)", "a", "a", 580);
func_mysqli_fetch_all($link, $engine, "VARCHAR(255)", $string255, $string255, 590);
func_mysqli_fetch_all($link, $engine, "VARCHAR(16000)", $string16k, $string16k, 600);
func_mysqli_fetch_all($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610);
func_mysqli_fetch_all($link, $engine, "VARCHAR(1)", NULL, NULL, 620);
func_mysqli_fetch_all($link, $engine, "BINARY(1)", "a", "a", 630);
func_mysqli_fetch_all($link, $engine, "BINARY(2)", chr(0) . "a", chr(0) . "a", 640);
func_mysqli_fetch_all($link, $engine, "BINARY(1) NOT NULL", "b", "b", 650);
func_mysqli_fetch_all($link, $engine, "BINARY(1)", NULL, NULL, 660);
func_mysqli_fetch_all($link, $engine, "VARBINARY(1)", "a", "a", 670);
func_mysqli_fetch_all($link, $engine, "VARBINARY(2)", chr(0) . "a", chr(0) . "a", 680);
func_mysqli_fetch_all($link, $engine, "VARBINARY(1) NOT NULL", "b", "b", 690);
func_mysqli_fetch_all($link, $engine, "VARBINARY(1)", NULL, NULL, 700);
func_mysqli_fetch_all($link, $engine, "TINYBLOB", "a", "a", 710);
func_mysqli_fetch_all($link, $engine, "TINYBLOB", chr(0) . "a", chr(0) . "a", 720);
func_mysqli_fetch_all($link, $engine, "TINYBLOB NOT NULL", "b", "b", 730);
func_mysqli_fetch_all($link, $engine, "TINYBLOB", NULL, NULL, 740);
func_mysqli_fetch_all($link, $engine, "TINYTEXT", "a", "a", 750);
func_mysqli_fetch_all($link, $engine, "TINYTEXT NOT NULL", "a", "a", 760);
func_mysqli_fetch_all($link, $engine, "TINYTEXT", NULL, NULL, 770);
func_mysqli_fetch_all($link, $engine, "BLOB", "a", "a", 780);
func_mysqli_fetch_all($link, $engine, "BLOB", chr(0) . "a", chr(0) . "a", 780);
func_mysqli_fetch_all($link, $engine, "BLOB", NULL, NULL, 790);
func_mysqli_fetch_all($link, $engine, "TEXT", "a", "a", 800);
func_mysqli_fetch_all($link, $engine, "TEXT", chr(0) . "a", chr(0) . "a", 810);
func_mysqli_fetch_all($link, $engine, "TEXT", NULL, NULL, 820);
func_mysqli_fetch_all($link, $engine, "MEDIUMBLOB", "a", "a", 830);
func_mysqli_fetch_all($link, $engine, "MEDIUMBLOB", chr(0) . "a", chr(0) . "a", 840);
func_mysqli_fetch_all($link, $engine, "MEDIUMBLOB", NULL, NULL, 850);
func_mysqli_fetch_all($link, $engine, "MEDIUMTEXT", "a", "a", 860);
func_mysqli_fetch_all($link, $engine, "MEDIUMTEXT", chr(0) . "a", chr(0) . "a", 870);
func_mysqli_fetch_all($link, $engine, "MEDIUMTEXT", NULL, NULL, 880);
func_mysqli_fetch_all($link, $engine, "LONGBLOB", "a", "a", 890);
func_mysqli_fetch_all($link, $engine, "LONGTEXT", chr(0) . "a", chr(0) . "a", 900);
func_mysqli_fetch_all($link, $engine, "LONGBLOB", NULL, NULL, 910);
func_mysqli_fetch_all($link, $engine, "ENUM('a', 'b')", "a", "a", 920);
func_mysqli_fetch_all($link, $engine, "ENUM('a', 'b')", NULL, NULL, 930);
func_mysqli_fetch_all($link, $engine, "SET('a', 'b')", "a", "a", 940);
func_mysqli_fetch_all($link, $engine, "SET('a', 'b')", NULL, NULL, 950);
mysqli_close($link);
// TODO Split below into new test?
$link = default_mysqli_connect();
mysqli_real_query($link, "SELECT 1 AS _one");
$result = mysqli_use_result($link);
/* on mysqlnd level this would not be allowed */
if (!is_object($result)) {
printf("[018] Expecting object, got %s/%s. [%d] %s\n",
gettype($result), $result, mysqli_errno($link), mysqli_error($link));
}
$rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
if (!is_array($rows) || (count($rows) > 1) || !isset($rows[0]['_one']) || ($rows[0]['_one'] != 1)) {
printf("[019] Results seem wrong, dumping\n");
var_dump($rows);
}
print "OK";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_mysqli_fetch_all_data_types_variation');
?>
--EXPECT--
OK

View File

@@ -0,0 +1,33 @@
--TEST--
function test: mysqli_affected_rows
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query($link, "CREATE TABLE test_mysqli_affected_rows (a INT)");
mysqli_query($link, "INSERT INTO test_mysqli_affected_rows VALUES (1),(2),(3)");
$afc = mysqli_affected_rows($link);
var_dump($afc);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_mysqli_affected_rows');
?>
--EXPECT--
int(3)
done!

View File

@@ -0,0 +1,41 @@
--TEST--
function test: mysqli_character_set_name
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
$result = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation');
$tmp = mysqli_fetch_assoc($result);
mysqli_free_result($result);
if (!$tmp['charset']) {
throw new Exception("Cannot determine current character set and collation");
}
$charset = mysqli_character_set_name($link);
if ($tmp['charset'] !== $charset) {
printf("[001] Expecting character set %s/%s, got %s/%s\n", get_debug_type($tmp['charset']), $tmp['charset'], get_debug_type($charset), $charset);
}
mysqli_close($link);
try {
mysqli_character_set_name($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECT--
mysqli object is already closed
done!

View File

@@ -0,0 +1,41 @@
--TEST--
function test: mysqli_character_set_name
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
$result = $link->query('SELECT @@character_set_connection AS charset, @@collation_connection AS collation');
$tmp = $result->fetch_assoc();
$result->free_result();
if (!$tmp['charset']) {
throw new Exception("Cannot determine current character set and collation");
}
$charset = $link->character_set_name();
if ($tmp['charset'] !== $charset) {
printf("[001] Expecting character set %s/%s, got %s/%s\n", get_debug_type($tmp['charset']), $tmp['charset'], get_debug_type($charset), $charset);
}
$link->close();
try {
$link->character_set_name();
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECT--
mysqli object is already closed
done!

View File

@@ -0,0 +1,32 @@
--TEST--
function test: mysqli_errno
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
/* Disable exceptions */
mysqli_report(MYSQLI_REPORT_OFF);
$link = default_mysqli_connect();
$errno = mysqli_errno($link);
var_dump($errno);
mysqli_query($link, "SELECT * FROM non_existing_table");
$errno = mysqli_errno($link);
var_dump($errno);
mysqli_close($link);
print "done!";
?>
--EXPECT--
int(0)
int(1146)
done!

View File

@@ -0,0 +1,32 @@
--TEST--
function test: mysqli_error
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
/* Disable exceptions */
mysqli_report(MYSQLI_REPORT_OFF);
$link = default_mysqli_connect();
$error = mysqli_error($link);
var_dump($error);
mysqli_query($link, "SELECT * FROM non_existing_table");
$error = mysqli_error($link);
var_dump($error);
mysqli_close($link);
print "done!";
?>
--EXPECTF--
string(0) ""
string(%d) "%s"
done!

View File

@@ -0,0 +1,42 @@
--TEST--
function test: mysqli_field_count()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query($link, "CREATE TABLE test_mysqli_field_count (a int, b varchar(10)) ENGINE = " . get_default_db_engine());
mysqli_query($link, "INSERT INTO test_mysqli_field_count VALUES (1, 'foo')");
$ir[] = mysqli_field_count($link);
mysqli_real_query($link, "SELECT * FROM test_mysqli_field_count");
$ir[] = mysqli_field_count($link);
var_dump($ir);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once(dirname(__DIR__) . "/test_setup/test_helpers.inc");
tear_down_table_on_default_connection('test_mysqli_field_count');
?>
--EXPECT--
array(2) {
[0]=>
int(0)
[1]=>
int(2)
}
done!

View File

@@ -0,0 +1,12 @@
--TEST--
function test: mysqli_get_client_info
--EXTENSIONS--
mysqli
--FILE--
<?php
// As of PHP 8.2.0 cannot be linked against libmysql anymore
$expected_version = 'mysqlnd ' . PHP_VERSION;
var_dump(mysqli_get_client_info() === $expected_version);
?>
--EXPECT--
bool(true)

View File

@@ -4,14 +4,14 @@ function test: mysqli_get_host_info
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once 'connect.inc';
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$link = default_mysqli_connect();
$hinfo = mysqli_get_host_info($link);

View File

@@ -4,14 +4,14 @@ function test: mysqli_get_proto_info
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once 'connect.inc';
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$link = default_mysqli_connect();
$pinfo = mysqli_get_proto_info($link);

View File

@@ -4,14 +4,14 @@ mysqli_get_server_version
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once 'connect.inc';
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$link = default_mysqli_connect();
$i = mysqli_get_server_version($link);

View File

@@ -0,0 +1,33 @@
--TEST--
function test: mysqli_info
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query($link, "CREATE TABLE test_mysqli_info (a INT)");
mysqli_query($link, "INSERT INTO test_mysqli_info VALUES (1),(2),(3)");
$afc = mysqli_info($link);
var_dump($afc);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once(dirname(__DIR__) . "/test_setup/test_helpers.inc");
tear_down_table_on_default_connection('test_mysqli_info');
?>
--EXPECT--
string(38) "Records: 3 Duplicates: 0 Warnings: 0"
done!

View File

@@ -0,0 +1,37 @@
--TEST--
function test: mysqli_num_fields()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query($link, "CREATE TABLE test_mysqli_num_fields (a int, b varchar(10)) ENGINE = " . get_default_db_engine());
mysqli_query($link, "INSERT INTO test_mysqli_num_fields VALUES (1, 'foo')");
mysqli_real_query($link, "SELECT * FROM test_mysqli_num_fields");
if (mysqli_field_count($link)) {
$result = mysqli_store_result($link);
$num = mysqli_num_fields($result);
mysqli_free_result($result);
}
var_dump($num);
mysqli_close($link);
?>
--CLEAN--
<?php
require_once(dirname(__DIR__) . "/test_setup/test_helpers.inc");
tear_down_table_on_default_connection('test_mysqli_num_fields');
?>
--EXPECT--
int(2)

View File

@@ -4,14 +4,14 @@ function test: mysqli_num_fields() 2
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once 'connect.inc';
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$link = default_mysqli_connect();
mysqli_real_query($link, "SHOW VARIABLES");

View File

@@ -0,0 +1,38 @@
--TEST--
function test: mysqli_num_rows()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query($link, "CREATE TABLE test_mysqli_num_rows (a int, b varchar(10)) ENGINE=" . get_default_db_engine());
mysqli_query($link, "INSERT INTO test_mysqli_num_rows VALUES (1, 'foo')");
mysqli_real_query($link, "SELECT * FROM test_mysqli_num_rows");
if (mysqli_field_count($link)) {
$result = mysqli_store_result($link);
$num = mysqli_num_rows($result);
mysqli_free_result($result);
}
var_dump($num);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_mysqli_num_rows');
?>
--EXPECT--
int(1)
done!

View File

@@ -0,0 +1,84 @@
--TEST--
Fetching results from tables of different charsets.
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
/** This test requires MySQL Server 4.1+, which is now assumed */
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
$result = mysqli_query($link, 'SHOW CHARACTER SET');
$charsets = [];
while ($row = mysqli_fetch_assoc($result)) {
$charsets[] = $row['Charset'];
}
mysqli_free_result($result);
/* The server currently 17.07.2007 can't handle data sent in ucs2 */
/* The server currently 16.08.2010 can't handle data sent in utf16 and utf32 */
/* The server currently 02.09.2011 can't handle data sent in utf16le */
/* As of MySQL 8.0.28, `SHOW CHARACTER SET` contains utf8mb3, but that is not yet supported by mysqlnd */
const UNSUPPORTED_ENCODINGS = [
'ucs2',
'utf16',
'utf32',
'utf16le',
'utf8mb3',
];
foreach ($charsets as $charset) {
if (in_array($charset, UNSUPPORTED_ENCODINGS, true)) {
continue;
}
$sql = sprintf("CREATE TABLE test_mysqli_set_charset(id INT, label CHAR(1)) CHARACTER SET '%s' ", $charset);
mysqli_query($link, $sql);
mysqli_set_charset($link, $charset);
for ($i = 1; $i <= 3; $i++) {
mysqli_query(
$link,
sprintf(
"INSERT INTO test_mysqli_set_charset (id, label) VALUES (%d, '%s')",
$i,
mysqli_real_escape_string($link, chr(ord("a") + $i))
)
);
}
$result = mysqli_query($link, "SELECT id, label FROM test_mysqli_set_charset");
for ($i = 1; $i <= 3; $i++) {
$tmp = mysqli_fetch_assoc($result);
if ($tmp['id'] != $i)
printf("[012 + %s] Expecting %d, got %s, [%d] %s\n", $charset,
$i, $tmp['id'],
mysqli_errno($link), mysqli_error($link));
if ($tmp['label'] != chr(ord("a") + $i))
printf("[013 + %s] Expecting %d, got %s, [%d] %s\n", $charset,
chr(ord("a") + $i), $tmp['label'],
mysqli_errno($link), mysqli_error($link));
}
mysqli_free_result($result);
mysqli_query($link, "DROP TABLE test_mysqli_set_charset");
}
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_mysqli_set_charset');
?>
--EXPECT--
done!

View File

@@ -4,14 +4,14 @@ function test: mysqli_stat
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once 'connect.inc';
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$link = default_mysqli_connect();
$status = mysqli_stat($link);

View File

@@ -0,0 +1,31 @@
--TEST--
function test: mysqli_warning_count()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_query($link, "DROP TABLE IF EXISTS test_mysqli_warning_count");
mysqli_query($link, "DROP TABLE IF EXISTS test_mysqli_warning_count");
var_dump(mysqli_warning_count($link));
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_mysqli_warning_count');
?>
--EXPECT--
int(1)
done!

View File

@@ -1,93 +0,0 @@
--TEST--
Fetching results from tables of different charsets.
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
$tmp = NULL;
$link = NULL;
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
if (!$res = mysqli_query($link, "SHOW CHARACTER SET"))
printf("[005] Cannot get list of available character sets, [%d] %s\n",
mysqli_errno($link), mysqli_error($link));
$charsets = array();
while ($row = mysqli_fetch_assoc($res))
$charsets[] = $row;
mysqli_free_result($res);
foreach ($charsets as $charset) {
$k = $charset['Charset'];
/* The server currently 17.07.2007 can't handle data sent in ucs2 */
/* The server currently 16.08.2010 can't handle data sent in utf16 and utf32 */
/* The server currently 02.09.2011 can't handle data sent in utf16le */
/* As of MySQL 8.0.28, `SHOW CHARACTER SET` contains utf8mb3, but that is not yet supported by mysqlnd */
if ($charset['Charset'] == 'ucs2' || $charset['Charset'] == 'utf16' || $charset['Charset'] == 'utf32' || 'utf16le' == $charset['Charset'] || 'utf8mb3' == $charset['Charset']) {
continue;
}
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
printf("[006 + %s] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
$sql = sprintf("CREATE TABLE test(id INT, label CHAR(1)) CHARACTER SET '%s' ", $charset['Charset']);
if (!mysqli_query($link, $sql)) {
printf("[007 + %s] %s [%d] %s\n", $k, $sql, mysqli_errno($link), mysqli_error($link));
continue;
}
if (!mysqli_set_charset($link, $charset['Charset'])) {
printf("[008 + %s] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
continue;
}
for ($i = 1; $i <= 3; $i++) {
if (!mysqli_query($link, sprintf("INSERT INTO test (id, label) VALUES (%d, '%s')",
$i, mysqli_real_escape_string($link, chr(ord("a") + $i)))))
{
var_dump($charset['Charset']);
printf("[009 + %s] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
continue;
}
}
if (!$res = mysqli_query($link, "SELECT id, label FROM test"))
printf("[010 + %s] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
for ($i = 1; $i <= 3; $i++) {
if (!$tmp = mysqli_fetch_assoc($res))
printf("[011 + %s] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
if ($tmp['id'] != $i)
printf("[012 + %s] Expecting %d, got %s, [%d] %s\n", $k,
$i, $tmp['id'],
mysqli_errno($link), mysqli_error($link));
if ($tmp['label'] != chr(ord("a") + $i))
printf("[013 + %s] Expecting %d, got %s, [%d] %s\n", $k,
chr(ord("a") + $i), $tmp['label'],
mysqli_errno($link), mysqli_error($link));
}
mysqli_free_result($res);
}
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once 'clean_table.inc';
?>
--EXPECT--
done!

View File

@@ -1,45 +0,0 @@
--TEST--
mysqli_character_set_name()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
/* NOTE: http://bugs.mysql.com/bug.php?id=7923 makes this test fail very likely on all 4.1.x - 5.0.x! */
require_once 'connect.inc';
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
if (!$res = mysqli_query($link, 'SELECT @@character_set_connection AS charset, @@collation_connection AS collation'))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$tmp = mysqli_fetch_assoc($res);
mysqli_free_result($res);
if (!$tmp['charset'])
printf("[002] Cannot determine current character set and collation\n");
$charset = mysqli_character_set_name($link);
if ($tmp['charset'] !== $charset) {
if ($tmp['collation'] === $charset) {
printf("[003] Could be known server bug http://bugs.mysql.com/bug.php?id=7923, collation %s instead of character set returned, expected string/%s, got %s/%s\n",
$tmp['collation'], $tmp['charset'], gettype($charset), $charset);
} else {
printf("[004] Expecting character set %s/%s, got %s/%s\n", gettype($tmp['charset']), $tmp['charset'], gettype($charset), $charset);
}
}
mysqli_close($link);
try {
mysqli_character_set_name($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECT--
mysqli object is already closed
done!

View File

@@ -1,45 +0,0 @@
--TEST--
mysqli_character_set_name()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
/* NOTE: http://bugs.mysql.com/bug.php?id=7923 makes this test fail very likely on all 4.1.x - 5.0.x! */
require_once 'connect.inc';
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
if (!$res = $mysqli->query('SELECT @@character_set_connection AS charset, @@collation_connection AS collation'))
printf("[001] [%d] %s\n", $mysqli->errno, $mysqli->error);
$tmp = $res->fetch_assoc();
$res->free_result();
if (!$tmp['charset'])
printf("[002] Cannot determine current character set and collation\n");
$charset = $mysqli->character_set_name();
if ($tmp['charset'] !== $charset) {
if ($tmp['collation'] === $charset) {
printf("[003] Could be known server bug http://bugs.mysql.com/bug.php?id=7923, collation %s instead of character set returned, expected string/%s, got %s/%s\n",
$tmp['collation'], $tmp['charset'], gettype($charset), $charset);
} else {
printf("[004] Expecting character set %s/%s, got %s/%s\n", gettype($tmp['charset']), $tmp['charset'], gettype($charset), $charset);
}
}
$mysqli->close();
try {
$mysqli->character_set_name();
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECT--
my_mysqli object is already closed
done!

View File

@@ -1,5 +1,5 @@
--TEST--
Writing to mysqli properties
Writing to mysqli_driver properties
--EXTENSIONS--
mysqli
--FILE--

View File

@@ -1,5 +1,5 @@
--TEST--
Writing to mysqli properties (strict_types)
Writing to mysqli_driver properties (strict_types)
--EXTENSIONS--
mysqli
--FILE--

View File

@@ -1,445 +0,0 @@
--TEST--
mysqli_fetch_all()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require 'table.inc';
if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id LIMIT 2")) {
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
print "[005]\n";
var_dump(mysqli_fetch_all($res));
mysqli_free_result($res);
if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id LIMIT 2")) {
printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
print "[007]\n";
var_dump(mysqli_fetch_all($res, MYSQLI_NUM));
mysqli_free_result($res);
if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id LIMIT 2")) {
printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
print "[008]\n";
var_dump(mysqli_fetch_all($res, MYSQLI_BOTH));
mysqli_free_result($res);
if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id LIMIT 2")) {
printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
print "[010]\n";
var_dump(mysqli_fetch_all($res, MYSQLI_ASSOC));
print "[011]\n";
var_dump(mysqli_fetch_all($res));
mysqli_free_result($res);
if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id LIMIT 2")) {
printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
print "[013]\n";
var_dump(mysqli_fetch_all($res, MYSQLI_ASSOC));
print "[016]\n";
var_dump(mysqli_fetch_all($res));
if (!$res = mysqli_query($link, "SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e")) {
printf("[010] Cannot run query, [%d] %s\n", mysqli_errno($link), $mysqli_error($link));
}
print "[017]\n";
var_dump(mysqli_fetch_all($res, MYSQLI_BOTH));
mysqli_free_result($res);
if (!$res = mysqli_query($link, "SELECT 1 AS a, 2 AS b, 3 AS c, 4 AS C")) {
printf("[018] Cannot run query, [%d] %s\n",
mysqli_errno($link), $mysqli_error($link));
exit(1);
}
// Illegal mode
try {
mysqli_fetch_all($res, -10);
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
mysqli_free_result($res);
function func_mysqli_fetch_all($link, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL) {
if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
return false;
}
if (!mysqli_query($link, $sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) {
// don't bail, engine might not support the datatype
return false;
}
if (is_null($php_value)) {
if (!mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) {
printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
return false;
}
} else {
if (is_string($sql_value)) {
if (!mysqli_query($link, $sql = "INSERT INTO test(id, label) VALUES (1, '" . $sql_value . "')")) {
printf("[%04ds] [%d] %s - %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link), $sql);
return false;
}
} else {
if (!mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) {
printf("[%04di] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link));
return false;
}
}
}
if (!$res = mysqli_query($link, "SELECT id, label FROM test")) {
printf("[%04d] [%d] %s\n", $offset + 2, mysqli_errno($link), mysqli_error($link));
return false;
}
if (!$tmp = mysqli_fetch_all($res, MYSQLI_BOTH)) {
printf("[%04d] [%d] %s\n", $offset + 3, mysqli_errno($link), mysqli_error($link));
return false;
}
$row = $tmp[0];
$fields = mysqli_fetch_fields($res);
if (!(gettype($php_value)=="unicode" && ($fields[1]->flags & 128))) {
if ($regexp_comparison) {
if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) {
printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,
gettype($php_value), $php_value, $regexp_comparison,
gettype($row[1]), $row[1],
gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link));
return false;
}
} else {
if (($row['label'] !== $php_value) || ($row[1] != $php_value)) {
printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,
gettype($php_value), $php_value,
gettype($row[1]), $row[1],
gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link));
return false;
}
}
}
return true;
}
function func_mysqli_fetch_array_make_string($len) {
$ret = '';
for ($i = 0; $i < $len; $i++)
$ret .= chr(mt_rand(65, 90));
return $ret;
}
func_mysqli_fetch_all($link, $engine, "TINYINT", -11, "-11", 20);
func_mysqli_fetch_all($link, $engine, "TINYINT", NULL, NULL, 30);
func_mysqli_fetch_all($link, $engine, "TINYINT UNSIGNED", 1, "1", 40);
func_mysqli_fetch_all($link, $engine, "TINYINT UNSIGNED", NULL, NULL, 50);
func_mysqli_fetch_all($link, $engine, "BOOL", 1, "1", 60);
func_mysqli_fetch_all($link, $engine, "BOOL", NULL, NULL, 70);
func_mysqli_fetch_all($link, $engine, "BOOLEAN", 0, "0", 80);
func_mysqli_fetch_all($link, $engine, "BOOLEAN", NULL, NULL, 90);
func_mysqli_fetch_all($link, $engine, "SMALLINT", -32768, "-32768", 100);
func_mysqli_fetch_all($link, $engine, "SMALLINT", 32767, "32767", 110);
func_mysqli_fetch_all($link, $engine, "SMALLINT", NULL, NULL, 120);
func_mysqli_fetch_all($link, $engine, "SMALLINT UNSIGNED", 65535, "65535", 130);
func_mysqli_fetch_all($link, $engine, "SMALLINT UNSIGNED", NULL, NULL, 140);
func_mysqli_fetch_all($link, $engine, "MEDIUMINT", -8388608, "-8388608", 150);
func_mysqli_fetch_all($link, $engine, "MEDIUMINT", 8388607, "8388607", 160);
func_mysqli_fetch_all($link, $engine, "MEDIUMINT", NULL, NULL, 170);
func_mysqli_fetch_all($link, $engine, "MEDIUMINT UNSIGNED", 16777215, "16777215", 180);
func_mysqli_fetch_all($link, $engine, "MEDIUMINT UNSIGNED", NULL, NULL, 190);
func_mysqli_fetch_all($link, $engine, "INTEGER", -2147483648, "-2147483648", 200);
func_mysqli_fetch_all($link, $engine, "INTEGER", 2147483647, "2147483647", 210);
func_mysqli_fetch_all($link, $engine, "INTEGER", NULL, NULL, 220);
func_mysqli_fetch_all($link, $engine, "INTEGER UNSIGNED", "4294967295", "4294967295", 230);
func_mysqli_fetch_all($link, $engine, "INTEGER UNSIGNED", NULL, NULL, 240);
func_mysqli_fetch_all($link, $engine, "BIGINT", "-9223372036854775808", "-9223372036854775808", 250);
func_mysqli_fetch_all($link, $engine, "BIGINT", NULL, NULL, 260);
func_mysqli_fetch_all($link, $engine, "BIGINT UNSIGNED", "18446744073709551615", "18446744073709551615", 270);
func_mysqli_fetch_all($link, $engine, "BIGINT UNSIGNED", NULL, NULL, 280);
func_mysqli_fetch_all($link, $engine, "FLOAT", (string)(-9223372036854775808 - 1.1), "-9.22337e+18", 290, "/-9\.22337e\+?[0]?18/iu");
func_mysqli_fetch_all($link, $engine, "FLOAT", NULL, NULL, 300);
func_mysqli_fetch_all($link, $engine, "FLOAT UNSIGNED", (string)(18446744073709551615 + 1.1), "1.84467e+19", 310, "/1\.84467e\+?[0]?19/iu");
func_mysqli_fetch_all($link, $engine, "FLOAT UNSIGNED ", NULL, NULL, 320);
func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2)", "-99999999.99", "-99999999.99", 330);
func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2)", NULL, NULL, 340);
func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2) UNSIGNED", "99999999.99", "99999999.99", 350);
func_mysqli_fetch_all($link, $engine, "DOUBLE(10,2) UNSIGNED", NULL, NULL, 360);
func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", "-99999999.99", "-99999999.99", 370);
func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", NULL, NULL, 380);
func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", "99999999.99", "99999999.99", 390);
func_mysqli_fetch_all($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400);
// don't care about date() strict TZ warnings...
func_mysqli_fetch_all($link, $engine, "DATE", @date('Y-m-d'), @date('Y-m-d'), 410);
func_mysqli_fetch_all($link, $engine, "DATE NOT NULL", @date('Y-m-d'), @date('Y-m-d'), 420);
func_mysqli_fetch_all($link, $engine, "DATE", NULL, NULL, 430);
func_mysqli_fetch_all($link, $engine, "DATETIME", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 440);
func_mysqli_fetch_all($link, $engine, "DATETIME NOT NULL", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 450);
func_mysqli_fetch_all($link, $engine, "DATETIME", NULL, NULL, 460);
func_mysqli_fetch_all($link, $engine, "TIMESTAMP", @date('Y-m-d H:i:s'), @date('Y-m-d H:i:s'), 470);
func_mysqli_fetch_all($link, $engine, "TIME", @date('H:i:s'), @date('H:i:s'), 480);
func_mysqli_fetch_all($link, $engine, "TIME NOT NULL", @date('H:i:s'), @date('H:i:s'), 490);
func_mysqli_fetch_all($link, $engine, "TIME", NULL, NULL, 500);
func_mysqli_fetch_all($link, $engine, "YEAR", @date('Y'), @date('Y'), 510);
func_mysqli_fetch_all($link, $engine, "YEAR NOT NULL", @date('Y'), @date('Y'), 520);
func_mysqli_fetch_all($link, $engine, "YEAR", NULL, NULL, 530);
$string255 = func_mysqli_fetch_array_make_string(255);
func_mysqli_fetch_all($link, $engine, "CHAR(1)", "a", "a", 540);
func_mysqli_fetch_all($link, $engine, "CHAR(255)", $string255, $string255, 550);
func_mysqli_fetch_all($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560);
func_mysqli_fetch_all($link, $engine, "CHAR(1)", NULL, NULL, 570);
$string65k = func_mysqli_fetch_array_make_string(65400);
func_mysqli_fetch_all($link, $engine, "VARCHAR(1)", "a", "a", 580);
func_mysqli_fetch_all($link, $engine, "VARCHAR(255)", $string255, $string255, 590);
func_mysqli_fetch_all($link, $engine, "VARCHAR(65400)", $string65k, $string65k, 600);
func_mysqli_fetch_all($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610);
func_mysqli_fetch_all($link, $engine, "VARCHAR(1)", NULL, NULL, 620);
func_mysqli_fetch_all($link, $engine, "BINARY(1)", "a", "a", 630);
func_mysqli_fetch_all($link, $engine, "BINARY(2)", chr(0) . "a", chr(0) . "a", 640);
func_mysqli_fetch_all($link, $engine, "BINARY(1) NOT NULL", "b", "b", 650);
func_mysqli_fetch_all($link, $engine, "BINARY(1)", NULL, NULL, 660);
func_mysqli_fetch_all($link, $engine, "VARBINARY(1)", "a", "a", 670);
func_mysqli_fetch_all($link, $engine, "VARBINARY(2)", chr(0) . "a", chr(0) . "a", 680);
func_mysqli_fetch_all($link, $engine, "VARBINARY(1) NOT NULL", "b", "b", 690);
func_mysqli_fetch_all($link, $engine, "VARBINARY(1)", NULL, NULL, 700);
func_mysqli_fetch_all($link, $engine, "TINYBLOB", "a", "a", 710);
func_mysqli_fetch_all($link, $engine, "TINYBLOB", chr(0) . "a", chr(0) . "a", 720);
func_mysqli_fetch_all($link, $engine, "TINYBLOB NOT NULL", "b", "b", 730);
func_mysqli_fetch_all($link, $engine, "TINYBLOB", NULL, NULL, 740);
func_mysqli_fetch_all($link, $engine, "TINYTEXT", "a", "a", 750);
func_mysqli_fetch_all($link, $engine, "TINYTEXT NOT NULL", "a", "a", 760);
func_mysqli_fetch_all($link, $engine, "TINYTEXT", NULL, NULL, 770);
func_mysqli_fetch_all($link, $engine, "BLOB", "a", "a", 780);
func_mysqli_fetch_all($link, $engine, "BLOB", chr(0) . "a", chr(0) . "a", 780);
func_mysqli_fetch_all($link, $engine, "BLOB", NULL, NULL, 790);
func_mysqli_fetch_all($link, $engine, "TEXT", "a", "a", 800);
func_mysqli_fetch_all($link, $engine, "TEXT", chr(0) . "a", chr(0) . "a", 810);
func_mysqli_fetch_all($link, $engine, "TEXT", NULL, NULL, 820);
func_mysqli_fetch_all($link, $engine, "MEDIUMBLOB", "a", "a", 830);
func_mysqli_fetch_all($link, $engine, "MEDIUMBLOB", chr(0) . "a", chr(0) . "a", 840);
func_mysqli_fetch_all($link, $engine, "MEDIUMBLOB", NULL, NULL, 850);
func_mysqli_fetch_all($link, $engine, "MEDIUMTEXT", "a", "a", 860);
func_mysqli_fetch_all($link, $engine, "MEDIUMTEXT", chr(0) . "a", chr(0) . "a", 870);
func_mysqli_fetch_all($link, $engine, "MEDIUMTEXT", NULL, NULL, 880);
func_mysqli_fetch_all($link, $engine, "LONGBLOB", "a", "a", 890);
func_mysqli_fetch_all($link, $engine, "LONGTEXT", chr(0) . "a", chr(0) . "a", 900);
func_mysqli_fetch_all($link, $engine, "LONGBLOB", NULL, NULL, 910);
func_mysqli_fetch_all($link, $engine, "ENUM('a', 'b')", "a", "a", 920);
func_mysqli_fetch_all($link, $engine, "ENUM('a', 'b')", NULL, NULL, 930);
func_mysqli_fetch_all($link, $engine, "SET('a', 'b')", "a", "a", 940);
func_mysqli_fetch_all($link, $engine, "SET('a', 'b')", NULL, NULL, 950);
mysqli_close($link);
try {
mysqli_fetch_array($res, MYSQLI_ASSOC);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[016] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
$host, $user, $db, $port, $socket);
}
if (!$res = mysqli_real_query($link, "SELECT 1 AS _one"))
printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
/* on mysqlnd level this would not be allowed */
if (!is_object($res = mysqli_use_result($link)))
printf("[018] Expecting object, got %s/%s. [%d] %s\n",
gettype($res), $res, mysqli_errno($link), mysqli_error($link));
$rows = mysqli_fetch_all($res, MYSQLI_ASSOC);
if (!is_array($rows) || (count($rows) > 1) || !isset($rows[0]['_one']) || ($rows[0]['_one'] != 1)) {
printf("[019] Results seem wrong, dumping\n");
var_dump($rows);
}
print "done!";
?>
--CLEAN--
<?php
// require_once 'clean_table.inc';
?>
--EXPECT--
[005]
array(2) {
[0]=>
array(2) {
[0]=>
string(1) "1"
[1]=>
string(1) "a"
}
[1]=>
array(2) {
[0]=>
string(1) "2"
[1]=>
string(1) "b"
}
}
[007]
array(2) {
[0]=>
array(2) {
[0]=>
string(1) "1"
[1]=>
string(1) "a"
}
[1]=>
array(2) {
[0]=>
string(1) "2"
[1]=>
string(1) "b"
}
}
[008]
array(2) {
[0]=>
array(4) {
[0]=>
string(1) "1"
["id"]=>
string(1) "1"
[1]=>
string(1) "a"
["label"]=>
string(1) "a"
}
[1]=>
array(4) {
[0]=>
string(1) "2"
["id"]=>
string(1) "2"
[1]=>
string(1) "b"
["label"]=>
string(1) "b"
}
}
[010]
array(2) {
[0]=>
array(2) {
["id"]=>
string(1) "1"
["label"]=>
string(1) "a"
}
[1]=>
array(2) {
["id"]=>
string(1) "2"
["label"]=>
string(1) "b"
}
}
[011]
array(0) {
}
[013]
array(2) {
[0]=>
array(2) {
["id"]=>
string(1) "1"
["label"]=>
string(1) "a"
}
[1]=>
array(2) {
["id"]=>
string(1) "2"
["label"]=>
string(1) "b"
}
}
[016]
array(0) {
}
[017]
array(1) {
[0]=>
array(11) {
[0]=>
string(1) "1"
["a"]=>
string(1) "2"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
["c"]=>
string(1) "3"
[3]=>
string(1) "4"
["C"]=>
string(1) "4"
[4]=>
NULL
["d"]=>
NULL
[5]=>
string(1) "1"
["e"]=>
string(1) "1"
}
}
mysqli_fetch_all(): Argument #2 ($mode) must be one of MYSQLI_NUM, MYSQLI_ASSOC, or MYSQLI_BOTH
mysqli_result object is already closed
done!

View File

@@ -0,0 +1,147 @@
<?php
function get_default_host(): string {
static $host = null;
if ($host === null) {
$host = getenv('MYSQL_TEST_HOST') ?: '127.0.0.1';
}
return $host;
}
function get_default_port(): int {
static $port = null;
if ($port === null) {
$port = getenv('MYSQL_TEST_PORT') ?: 3306;
}
return $port;
}
function get_default_user(): string {
static $user = null;
if ($user === null) {
$user = getenv('MYSQL_TEST_USER') ?: 'root';
}
return $user;
}
function get_default_password(): string {
static $password = null;
if ($password === null) {
$password = getenv('MYSQL_TEST_PASSWD') ?: '';
}
return $password;
}
function get_default_database(): string {
static $db = null;
if ($db === null) {
$db = getenv('MYSQL_TEST_DB') ?: 'test';
}
return $db;
}
function get_default_db_engine(): string {
static $engine = null;
if ($engine === null) {
$engine = getenv('MYSQL_TEST_ENGINE') ?: 'InnoDB';
}
return $engine;
}
function get_default_socket(): ?string {
/*
static $socket = null;
if ($socket === null) {
$socket = getenv('MYSQL_TEST_ENGINE') ?: null;
if ($socket) {
ini_set('mysqli.default_socket', $socket);
}
}
return $socket;
*/
return null;
}
function get_environment_connection_flags(): int {
static $connect_flags = null;
if ($connect_flags === null) {
$connect_flags = (int)getenv("MYSQL_TEST_CONNECT_FLAGS") ?: 0;
}
return $connect_flags;
}
/**
* Whenever possible, please use this wrapper to make testing of MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
*
* @param bool $enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)?
*/
function my_mysqli_connect(
string $host,
string $user,
string $password,
string $db,
int $port,
?string $socket = null,
bool $enable_env_flags = true
): \mysqli {
// Because the tests are meant to test both error modes, they can set the report_mode to a different value,
// which we do not want to override. However, we want to make sure that if a connection cannot be made,
// the constuctor will throw an exception. We store current report_mode in variable and restore it later.
$driver = new mysqli_driver;
$report_mode = $driver->report_mode;
$driver->report_mode = MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT;
$flags = $enable_env_flags ? get_environment_connection_flags() : 0;
if ($flags !== 0) {
$link = mysqli_init();
mysqli_real_connect($link, $host, $user, $password, $db, $port, $socket, $flags);
} else {
/* TODO Investigate why on LINUX_X64_RELEASE_NTS CI pipeline
* Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo for mysql failed:
* Temporary failure in name resolution in test_helpers.inc on line 91 */
$link = @mysqli_connect($host, $user, $password, $db, $port, $socket);
}
// Restore error mode
$driver->report_mode = $report_mode;
return $link;
}
function default_mysqli_connect(): \mysqli{
return my_mysqli_connect(
get_default_host(),
get_default_user(),
get_default_password(),
get_default_database(),
get_default_port(),
null,
);
}
function mysqli_check_skip_test(): void {
try {
$link = default_mysqli_connect();
} catch (\mysqli_sql_exception) {
die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
}
}
function have_innodb(mysqli $link): bool {
$res = $link->query("SELECT SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE = 'InnoDB'");
$supported = $res->fetch_column();
return $supported === 'YES' || $supported === 'DEFAULT';
}
function mysqli_check_innodb_support_skip_test(): void {
try {
$link = default_mysqli_connect();
} catch (\mysqli_sql_exception) {
die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
}
if (! have_innodb($link)) {
die(sprintf("skip Needs InnoDB support"));
}
}
function tear_down_table_on_default_connection(string $table) {
$link = default_mysqli_connect();
mysqli_query($link, 'DROP TABLE IF EXISTS ' . $table);
}
function setup_table_with_data_on_default_connection(string $table): mysqli {
$link = default_mysqli_connect();
mysqli_query($link, 'SET SESSION sql_mode=\'\'');
mysqli_query($link, 'CREATE TABLE '. $table .'(id INT DEFAULT 0, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . get_default_db_engine());
mysqli_query($link, 'INSERT INTO '. $table .'(id, label) VALUES (1, "a"), (2, "b"), (3, "c"), (4, "d"), (5, "e"), (6, "f")');
return $link;
}
/* Development setting: test experimental features and/or feature requests that never worked before? */
//$TEST_EXPERIMENTAL = 1 == getenv("MYSQL_TEST_EXPERIMENTAL");
//$engine = getenv("MYSQL_TEST_ENGINE") ?: "InnoDB";

View File

@@ -0,0 +1,72 @@
--TEST--
mysqli autocommit/commit/rollback with innodb with CACHE
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_innodb_support_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_autocommit($link, true);
mysqli_query($link,"CREATE TABLE test_transactions_14(a int, b varchar(10)) Engine=InnoDB");
mysqli_query($link, "INSERT INTO test_transactions_14 VALUES (1, 'foobar')");
mysqli_autocommit($link, false);
/* Modify data in DB */
mysqli_query($link, "DELETE FROM test_transactions_14");
mysqli_query($link, "INSERT INTO test_transactions_14 VALUES (2, 'egon')");
/* Attempt to rollback */
mysqli_rollback($link);
/* Check if rollback was successful */
$result = mysqli_query($link, "SELECT * FROM test_transactions_14");
printf("Num_of_rows=%d\n", mysqli_num_rows($result));
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
var_dump($row);
/* Modify data in DB */
mysqli_query($link, "DELETE FROM test_transactions_14");
mysqli_query($link, "INSERT INTO test_transactions_14 VALUES (2, 'egon')");
/* Commit modifications */
mysqli_commit($link);
/* Check if commit was successful */
$result = mysqli_query($link, "SELECT * FROM test_transactions_14");
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
var_dump($row);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_transactions_14');
?>
--EXPECT--
Num_of_rows=1
array(2) {
[0]=>
string(1) "1"
[1]=>
string(6) "foobar"
}
array(2) {
[0]=>
string(1) "2"
[1]=>
string(4) "egon"
}
done!

View File

@@ -0,0 +1,69 @@
--TEST--
mysqli autocommit/commit/rollback with innodb with SQL_NO_CACHE
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
mysqli_check_innodb_support_skip_test();
?>
--FILE--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
$link = default_mysqli_connect();
mysqli_autocommit($link, true);
mysqli_query($link,"CREATE TABLE test_transactions_15(a int, b varchar(10)) Engine=InnoDB");
mysqli_query($link, "INSERT INTO test_transactions_15 VALUES (1, 'foobar')");
mysqli_autocommit($link, false);
/* Modify data in DB */
mysqli_query($link, "DELETE FROM test_transactions_15");
mysqli_query($link, "INSERT INTO test_transactions_15 VALUES (2, 'egon')");
/* Attempt to rollback */
mysqli_rollback($link);
/* Check if rollback was successful */
$result = mysqli_query($link, "SELECT SQL_NO_CACHE * FROM test_transactions_15");
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
var_dump($row);
/* Modify data in DB */
mysqli_query($link, "DELETE FROM test_transactions_15");
mysqli_query($link, "INSERT INTO test_transactions_15 VALUES (2, 'egon')");
/* Commit modifications */
mysqli_commit($link);
/* Check if commit was successful */
$result = mysqli_query($link, "SELECT * FROM test_transactions_15");
$row = mysqli_fetch_row($result);
mysqli_free_result($result);
var_dump($row);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
tear_down_table_on_default_connection('test_transactions_15');
?>
--EXPECT--
array(2) {
[0]=>
string(1) "1"
[1]=>
string(6) "foobar"
}
array(2) {
[0]=>
string(1) "2"
[1]=>
string(4) "egon"
}
done!