1--TEST-- 2mysqli_stmt_free_result() 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifemb.inc'); 7require_once('skipifconnectfailure.inc'); 8?> 9--FILE-- 10<?php 11 /* 12 NOTE: no datatype tests here! This is done by 13 mysqli_stmt_bind_result.phpt already. Restrict 14 this test case to the basics. 15 */ 16 require_once("connect.inc"); 17 18 $tmp = NULL; 19 $link = NULL; 20 21 if (!is_null($tmp = @mysqli_stmt_free_result())) 22 printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 23 24 if (!is_null($tmp = @mysqli_stmt_free_result($link))) 25 printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 26 27 require('table.inc'); 28 29 if (!$stmt = mysqli_stmt_init($link)) 30 printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 31 32 // stmt object status test 33 if (false !== ($tmp = mysqli_stmt_free_result($stmt))) 34 printf("[004] Expecting false, got %s/%s\n", gettype($tmp), $tmp); 35 36 if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id")) 37 printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 38 39 if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) 40 printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 41 42 if (!mysqli_stmt_execute($stmt)) 43 printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 44 45 if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) 46 printf("[008] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 47 48 if (false !== ($tmp = mysqli_stmt_store_result($stmt))) 49 printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); 50 51 mysqli_stmt_close($stmt); 52 53 if (!$stmt = mysqli_stmt_init($link)) 54 printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 55 56 if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id")) 57 printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 58 59 if (!mysqli_stmt_execute($stmt)) 60 printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); 61 62 if (true !== ($tmp = mysqli_stmt_store_result($stmt))) 63 printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); 64 65 if (NULL !== ($tmp = mysqli_stmt_free_result($stmt))) 66 printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 67 68 mysqli_stmt_close($stmt); 69 70 if (false !== ($tmp = mysqli_stmt_free_result($stmt))) 71 printf("[015] Expecting false, got %s/%s\n", gettype($tmp), $tmp); 72 73 mysqli_close($link); 74 75 print "done!"; 76?> 77--CLEAN-- 78<?php 79 require_once("clean_table.inc"); 80?> 81--EXPECTF-- 82Warning: mysqli_stmt_free_result(): invalid object or resource mysqli_stmt 83 in %s on line %d 84 85Warning: mysqli_stmt_free_result(): Couldn't fetch mysqli_stmt in %s on line %d 86done! 87