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