1--TEST-- 2mysqli_stmt_param_count() 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_stmt_param_count())) 17 printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 18 19 if (!is_null($tmp = @mysqli_stmt_param_count($link))) 20 printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 21 22 require('table.inc'); 23 24 if (!$stmt = mysqli_stmt_init($link)) 25 printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 26 27 if (NULL !== ($tmp = mysqli_stmt_param_count($stmt))) 28 printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 29 30 function func_test_mysqli_stmt_param_count($stmt, $query, $expected, $offset) { 31 32 if (!mysqli_stmt_prepare($stmt, $query)) { 33 printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_error($stmt)); 34 return false; 35 } 36 37 if ($expected !== ($tmp = mysqli_stmt_param_count($stmt))) 38 printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 3, 39 gettype($expected), $expected, 40 gettype($tmp), $tmp); 41 return true; 42 } 43 44 func_test_mysqli_stmt_param_count($stmt, "SELECT 1 AS a", 0, 10); 45 func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id) VALUES (?)", 1, 20); 46 func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id, label) VALUES (?, ?)", 2, 30); 47 func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id, label) VALUES (?, '?')", 1, 40); 48 49 mysqli_stmt_close($stmt); 50 51 if (NULL !== ($tmp = mysqli_stmt_param_count($stmt))) 52 printf("[40] Expecting NULL, got %s/%s\n"); 53 54 mysqli_close($link); 55 56 /* Check that the function alias exists. It's a deprecated function, 57 but we have not announce the removal so far, therefore we need to check for it */ 58 if (!is_null($tmp = @mysqli_stmt_param_count())) 59 printf("[041] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 60 61 print "done!"; 62?> 63--CLEAN-- 64<?php 65 require_once("clean_table.inc"); 66?> 67--EXPECTF-- 68Warning: mysqli_stmt_param_count(): invalid object or resource mysqli_stmt 69 in %s on line %d 70 71Warning: mysqli_stmt_param_count(): Couldn't fetch mysqli_stmt in %s on line %d 72done!