/* temporary addition for Kent's setup, Win32 box */
for ($i = 0; $i < 10; $i++) {
- if (!$link = mysqli_init())
- printf("[001 + %d] mysqli_init() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());
+ if (!$link = mysqli_init())
+ printf("[001 + %d] mysqli_init() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());
- if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
- printf("[002 + %d] mysqli_real_connect() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());
+ if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
+ printf("[002 + %d] mysqli_real_connect() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());
- mysqli_close($link);
+ mysqli_close($link);
}
/*** test mysqli_real_connect compressed ***/
--TEST--
-mysqli bind_result 1
+mysqli bind_result 1
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
include "connect.inc";
-
+
/*** test mysqli_connect 127.0.0.1 ***/
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ 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);
+ 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_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11);
+ mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11);
mysqli_execute($stmt);
mysqli_fetch($stmt);
c4 bigint unsigned,
c5 bigint unsigned,
c6 bigint unsigned,
- c7 bigint unsigned) ENGINE=" . $engine);
+ 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) ".
- "VALUES (-23,4.0,33333333333333,0,-333333333333,99.9)");
+ $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_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
+ mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
mysqli_execute($stmt);
$rc = mysqli_fetch($stmt);
$c6 = 0;
}
}
- $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
+ $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);
?>
--EXPECTF--
-array(7) {
+array(8) {
[0]=>
int(5)
[1]=>
int(0)
[6]=>
int(100)
+ [7]=>
+ int(4567)
}
20123456
3123456789
done!
--UEXPECTF--
-array(7) {
+array(8) {
[0]=>
int(5)
[1]=>
int(0)
[6]=>
int(100)
+ [7]=>
+ int(4567)
}
20123456
3123456789
-done!
\ No newline at end of file
+done!
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result");
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))");
+ c3 timestamp(14),
+ c4 year,
+ c5 datetime,
+ c6 timestamp(4),
+ c7 timestamp(6))");
$stmt = mysqli_prepare($link, "INSERT INTO test_bind_result VALUES (?,?,?,?,?,?,?)");
mysqli_bind_param($stmt, "sssssss", $d1, $d2, $d3, $d4, $d5, $d6, $d7);
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)");
+ 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_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
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)");
+ 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_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
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)");
+ 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_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
mysqli_bind_result($stmt, $c1, $c2);
mysqli_fetch($stmt);
mysqli_stmt_close($stmt);
+ if (ini_get("unicode.semantics") && mysqli_get_server_version($link) < 50000) {
+ /* variables are binary */
+ settype($c1, "unicode");
+ settype($c2, "unicode");
+ }
$test = array ($c1,$c2);
var_dump($test);
[1]=>
unicode(%d) "%s"
}
-done!
\ No newline at end of file
+done!
$mysql->select_db($db);
$mysql->query("DROP TABLE IF EXISTS test_fetch_null");
- $mysql->query("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))");
+ $mysql->query("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))");
$mysql->query("INSERT INTO test_fetch_null(col1,col10, col11) VALUES(1,'foo1', 1000),(2,'foo2', 88),(3,'foo3', 389789)");
mysqli_query($link,"DROP TABLE IF EXISTS test_fetch");
mysqli_query($link,"CREATE TABLE test_fetch(c1 smallint unsigned,
- c2 smallint unsigned,
- c3 smallint,
- c4 smallint,
- c5 smallint,
- c6 smallint unsigned,
- c7 smallint)");
+ c2 smallint unsigned,
+ c3 smallint,
+ c4 smallint,
+ c5 smallint,
+ c6 smallint unsigned,
+ c7 smallint)");
mysqli_query($link, "INSERT INTO test_fetch VALUES ( -23, 35999, NULL, -500, -9999999, -0, 0)");
--TEST--
-set character set
+set character set
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
if (!function_exists('mysqli_set_charset')) {
die('skip mysqli_set_charset() not available');
}
include "connect.inc";
if (!$mysql = new mysqli($host, $user, $passwd, $db, $port, $socket))
- printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
-
+ printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+
if (!mysqli_query($mysql, "SET sql_mode=''"))
- printf("[002] Cannot set SQL-Mode, [%d] %s\n", mysqli_errno($mysql), mysqli_error($mysql));
+ printf("[002] Cannot set SQL-Mode, [%d] %s\n", mysqli_errno($mysql), mysqli_error($mysql));
$esc_str = chr(0xbf) . chr(0x5c);
$len = $charset = array();
if ($mysql->set_charset("latin1")) {
/* 5C should be escaped */
if (3 !== ($tmp = strlen($mysql->real_escape_string($esc_str))))
- printf("[003] Expecting 3/int got %s/%s\n", gettype($tmp), $tmp);
-
+ printf("[003] Expecting 3/int got %s/%s\n", gettype($tmp), $tmp);
+
if ('latin1' !== ($tmp = $mysql->client_encoding()))
- printf("[004] Expecting latin1/string got %s/%s\n", gettype($tmp), $tmp);
+ printf("[004] Expecting latin1/string got %s/%s\n", gettype($tmp), $tmp);
}
if ($res = $mysql->query("SHOW CHARACTER SET LIKE 'gbk'")) {
- $res->free_result();
- if ($mysql->set_charset("gbk")) {
- /* nothing should be escaped, it's a valid gbk character */
-
- if (2 !== ($tmp = strlen($mysql->real_escape_string($esc_str))))
- printf("[005] Expecting 2/int got %s/%s\n", gettype($tmp), $tmp);
-
- if ('gbk' !== ($tmp = $mysql->client_encoding()))
- printf("[005] Expecting gbk/string got %s/%s\n", gettype($tmp), $tmp);;
- }
+ $res->free_result();
+ if ($mysql->set_charset("gbk")) {
+ /* nothing should be escaped, it's a valid gbk character */
+
+ if (2 !== ($tmp = strlen($mysql->real_escape_string($esc_str))))
+ printf("[005] Expecting 2/int got %s/%s\n", gettype($tmp), $tmp);
+
+ if ('gbk' !== ($tmp = $mysql->client_encoding()))
+ printf("[005] Expecting gbk/string got %s/%s\n", gettype($tmp), $tmp);;
+ }
}
$mysql->close();
-
- print "done!";
+
+ print "done!";
?>
--EXPECT--
done!
\ No newline at end of file
/* skip cursor test for versions < 50004 */
if ((!$IS_MYSQLND && mysqli_get_client_version() < 50009) ||
- (mysqli_get_server_version($link) < 50009)) {
- die(sprintf("skip Client library doesn't support cursors (%s/%s)",
- mysqli_get_client_version(), mysqli_get_server_version($link));
+ (mysqli_get_server_version($link) < 50009)) {
+ die(sprintf("skip Client library doesn't support cursors (%s/%s)",
+ mysqli_get_client_version(), mysqli_get_server_version($link));
}
mysqli_close($link);
?>
function open_cursor($mysql, $query) {
if (!is_object($stmt = $mysql->prepare($query))) {
- printf("[001] Cannot create statement object for '%s', [%d] %s\n",
- $query, $mysql->errno, $mysql->error);
+ printf("[001] Cannot create statement object for '%s', [%d] %s\n",
+ $query, $mysql->errno, $mysql->error);
}
$stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY);
}
include "connect.inc";
- $a = array();
-
- /*** test mysqli_connect 127.0.0.1 ***/
$mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
+ if ((!$IS_MYSQLND && mysqli_get_client_version() < 50009) ||
+ (mysqli_get_server_version($mysql) < 50009)) {
+ /* we really want to skip it... */
+ die(var_dump(63));
+ }
+
+ $a = array();
+
for ($i=0;$i < 3; $i++) {
$mysql->query("DROP TABLE IF EXISTS cursor$i");
$mysql->query("CREATE TABLE cursor$i (a int not null) ENGINE=" . $engine);
<?php
- /*
- Default values are "localhost", "root",
- database "phptest" and empty password.
- Change the MYSQL_TEST environment values
- if you want to use another configuration
- */
-
+ /*
+ Default values are "localhost", "root",
+ database "phptest" and empty password.
+ Change the MYSQL_TEST environment values
+ if you want to use another configuration
+ */
+
$driver = new mysqli_driver;
$host = getenv("MYSQL_TEST_HOST") ? getenv("MYSQL_TEST_HOST") : "localhost";
$db = getenv("MYSQL_TEST_DB") ? getenv("MYSQL_TEST_DB") : "phptest";
$engine = getenv("MYSQL_TEST_ENGINE") ? getenv("MYSQL_TEST_ENGINE") : "MyISAM";
$socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null;
-
+
/* Development setting: test experimal features and/or feature requests that never worked before? */
- $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ?
- ((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? true : false) :
- false;
+ $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ?
+ ((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? true : false) :
+ false;
$IS_MYSQLND = stristr(mysqli_get_client_info(), "mysqlnd");
if (!$IS_MYSQLND) {
- $MYSQLND_VERSION = NULL;
+ $MYSQLND_VERSION = NULL;
} else {
- if (preg_match('@Revision:\s+(\d+)\s*\$@ism', mysqli_get_client_info(), $matches)) {
- $MYSQLND_VERSION = (int)$matches[1];
- } else {
- $MYSQLND_VERSION = -1;
- }
+ if (preg_match('@Revision:\s+(\d+)\s*\$@ism', mysqli_get_client_info(), $matches)) {
+ $MYSQLND_VERSION = (int)$matches[1];
+ } else {
+ $MYSQLND_VERSION = -1;
+ }
}
- if (!function_exists('sys_get_temp_dir')) {
- function sys_get_temp_dir() {
-
- if (!empty($_ENV['TMP']))
- return realpath( $_ENV['TMP'] );
- if (!empty($_ENV['TMPDIR']))
- return realpath( $_ENV['TMPDIR'] );
- if (!empty($_ENV['TEMP']))
- return realpath( $_ENV['TEMP'] );
-
- $temp_file = tempnam(md5(uniqid(rand(), TRUE)), '');
- if ($temp_file) {
- $temp_dir = realpath(dirname($temp_file));
- unlink($temp_file);
- return $temp_dir;
- }
- return FALSE;
- }
- }
+ if (!function_exists('sys_get_temp_dir')) {
+ function sys_get_temp_dir() {
+
+ if (!empty($_ENV['TMP']))
+ return realpath( $_ENV['TMP'] );
+ if (!empty($_ENV['TMPDIR']))
+ return realpath( $_ENV['TMPDIR'] );
+ if (!empty($_ENV['TEMP']))
+ return realpath( $_ENV['TEMP'] );
+
+ $temp_file = tempnam(md5(uniqid(rand(), TRUE)), '');
+ if ($temp_file) {
+ $temp_dir = realpath(dirname($temp_file));
+ unlink($temp_file);
+ return $temp_dir;
+ }
+ return FALSE;
+ }
+ }
?>
\ No newline at end of file
if (!extension_loaded('mysqli')){
die('skip mysqli extension not available');
}
-?>
+?>
\ No newline at end of file
<?php
- $driver = new mysqli_driver();
- if ($driver->embedded)
- die("skip test doesn't run with embedded server");
-?>
+ $driver = new mysqli_driver();
+ if ($driver->embedded)
+ die("skip test doesn't run with embedded server");
+?>
\ No newline at end of file
<?php
- $driver = new mysqli_driver();
- if (!$driver->embedded)
- die("skip test for with embedded server only");
-?>
+ $driver = new mysqli_driver();
+ if (!$driver->embedded)
+ die("skip test for with embedded server only");
+?>
\ No newline at end of file
require_once('connect.inc');
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
- printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
- exit(1);
-}
-
+ printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+ exit(1);
+}
+
if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
- printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- exit(1);
-}
-
+ printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ exit(1);
+}
+
if (!mysqli_query($link, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine)) {
- printf("Failed to create test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- exit(1);
+ printf("Failed to create test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ exit(1);
}
if (!mysqli_query($link, 'INSERT INTO test(id, label) VALUES (1, "a"), (2, "b"), (3, "c"), (4, "d"), (5, "e"), (6, "f")')) {
- printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
?>
\ No newline at end of file