1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
--TEST--
mysqli_info()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--INI--
mysqli.allow_local_infile=1
--FILE--
<?php
require 'table.inc';
if (false === mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'a')"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
// NOTE: empty string, no multiple insert syntax
if (!is_null($tmp = mysqli_info($link)) || ('' != $tmp))
printf("[004] Expecting null, got %s/%s\n", gettype($tmp), $tmp);
if (false === mysqli_query($link, "INSERT INTO test(id, label) VALUES (101, 'a'), (102, 'b')"))
printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
printf("[006] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
if (false === mysqli_query($link, 'INSERT INTO test(id, label) SELECT id + 200, label FROM test'))
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
printf("[008] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
if (false === mysqli_query($link, 'ALTER TABLE test MODIFY label CHAR(2)'))
printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
printf("[010] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
if (false === mysqli_query($link, "UPDATE test SET label = 'b' WHERE id >= 100"))
printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
printf("[012] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
if (false === mysqli_query($link, "SELECT 1"))
printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!is_null($tmp = mysqli_info($link)) || ('' != $tmp))
printf("[014] Expecting null, got %s/%s\n", gettype($tmp), $tmp);
// NOTE: no LOAD DATA INFILE test
if ($dir = sys_get_temp_dir()) {
do {
$file = $dir . '/' . 'mysqli_info_phpt.cvs';
if (!$fp = fopen($file, 'w'))
/* ignore this error */
break;
if (!fwrite($fp, "100;'a';\n") ||
!fwrite($fp, "101;'b';\n") ||
!fwrite($fp, "102;'c';\n")) {
@unlink($file);
break;
}
fclose($fp);
if (!mysqli_query($link, "DELETE FROM test")) {
printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
break;
}
if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY '\n'", $file))) {
/* ok, because we might not be allowed to do this */
@unlink($file);
break;
}
if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
printf("[016] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
unlink($file);
} while (false);
}
print "done!";
?>
--CLEAN--
<?php
require_once 'clean_table.inc';
?>
--EXPECT--
done!
|