1--TEST-- 2mysqli_kill() 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifemb.inc'); 7require_once('skipifconnectfailure.inc'); 8?> 9--FILE-- 10<?php 11 require_once("connect.inc"); 12 13 $tmp = NULL; 14 $link = NULL; 15 16 if (!is_null($tmp = @mysqli_kill())) 17 printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 18 19 if (!is_null($tmp = @mysqli_kill($link))) 20 printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 21 22 require('table.inc'); 23 24 // Zend will cast the NULL to 0 25 if (!is_bool($tmp = mysqli_kill($link, null))) 26 printf("[003] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); 27 28 if (!$thread_id = mysqli_thread_id($link)) 29 printf("[004] Cannot determine thread id, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 30 31 $tmp = mysqli_kill($link, $thread_id); 32 if (!is_bool($tmp)) 33 printf("[005] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); 34 35 if ($res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) 36 pintf("[006] Expecting boolean/false, got %s/%s\n", gettype($res), $res); 37 38 var_dump($error = mysqli_error($link)); 39 if (!is_string($error) || ('' === $error)) 40 printf("[007] Expecting string/any non empty, got %s/%s\n", gettype($error), $error); 41 var_dump($res); 42 var_dump($link); 43 if ($IS_MYSQLND) { 44 if ($link->info != 'Records: 6 Duplicates: 0 Warnings: 0') { 45 printf("[008] mysqlnd used to be more verbose and used to support SELECT\n"); 46 } 47 } else { 48 if ($link->info != NULL) { 49 printf("[008] Time for wonders - libmysql has started to support SELECT, change test\n"); 50 } 51 } 52 53 mysqli_close($link); 54 55 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 56 printf("[010] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 57 58 mysqli_kill($link, -1); 59 if ((!$res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) || 60 (!$tmp = mysqli_fetch_assoc($res))) { 61 printf("[011] Connection should not be gone, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 62 } 63 var_dump($tmp); 64 mysqli_free_result($res); 65 mysqli_close($link); 66 67 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 68 printf("[012] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); 69 70 mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1); 71 72 mysqli_close($link); 73 74 print "done!"; 75?> 76--CLEAN-- 77<?php 78 require_once("clean_table.inc"); 79?> 80--EXPECTF-- 81Warning: mysqli_kill(): processid should have positive value in %s on line %d 82string(%d) "%s" 83bool(false) 84object(mysqli)#%d (%d) { 85 ["affected_rows"]=> 86 int(-1) 87 ["client_info"]=> 88 string(%d) "%s" 89 ["client_version"]=> 90 int(%d) 91 ["connect_errno"]=> 92 int(0) 93 ["connect_error"]=> 94 NULL 95 ["errno"]=> 96 int(2006) 97 ["error"]=> 98 string(%d) "%s" 99 ["error_list"]=> 100 array(1) { 101 [0]=> 102 array(3) { 103 ["errno"]=> 104 int(2006) 105 ["sqlstate"]=> 106 string(5) "%s" 107 ["error"]=> 108 string(%d) "%s" 109 } 110 } 111 ["field_count"]=> 112 int(0) 113 ["host_info"]=> 114 string(%d) "%s" 115 ["info"]=> 116 %s 117 ["insert_id"]=> 118 int(0) 119 ["server_info"]=> 120 string(%d) "%s" 121 ["server_version"]=> 122 int(%d) 123 ["sqlstate"]=> 124 string(5) "HY000" 125 ["protocol_version"]=> 126 int(10) 127 ["thread_id"]=> 128 int(%d) 129 ["warning_count"]=> 130 int(0) 131} 132 133Warning: mysqli_kill(): processid should have positive value in %s on line %d 134array(1) { 135 ["id"]=> 136 string(1) "1" 137} 138 139Warning: mysqli_kill(): processid should have positive value in %s on line %d 140done! 141