1--TEST-- 2mysqli_stmt_attr_get() 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_attr_get())) 17 printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 18 19 if (!is_null($tmp = @mysqli_stmt_attr_get($link))) 20 printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 21 22 if (!is_null($tmp = @mysqli_stmt_attr_get($link, $link))) 23 printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 24 25 require('table.inc'); 26 27 if (!is_null($tmp = @mysqli_stmt_attr_get($link, $link))) 28 printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); 29 30 $valid_attr = array("max_length" => MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); 31 if (mysqli_get_client_version() > 50003) 32 $valid_attr["cursor_type"] = MYSQLI_STMT_ATTR_CURSOR_TYPE; 33 34 if ($IS_MYSQLND && mysqli_get_client_version() > 50007) 35 $valid_attr["prefetch_rows"] = MYSQLI_STMT_ATTR_PREFETCH_ROWS; 36 37 do { 38 $invalid_attr = mt_rand(0, 10000); 39 } while (in_array($invalid_attr, $valid_attr)); 40 41 $stmt = mysqli_stmt_init($link); 42 mysqli_stmt_prepare($stmt, 'SELECT * FROM test'); 43 if (false !== ($tmp = @mysqli_stmt_attr_get($stmt, $invalid_attr))) 44 printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); 45 46 foreach ($valid_attr as $k => $attr) { 47 if (false === ($tmp = mysqli_stmt_attr_get($stmt, $attr))) { 48 printf("[006] Expecting any type, but not boolean/false, got %s/%s for attribute %s/%s\n", 49 gettype($tmp), $tmp, $k, $attr); 50 } 51 } 52 53 $stmt->close(); 54 55 foreach ($valid_attr as $k => $attr) { 56 if (!is_null($tmp = @mysqli_stmt_attr_get($stmt, $attr))) { 57 printf("[007] Expecting NULL/NULL, got %s/%s for attribute %s/%s\n", 58 gettype($tmp), $tmp, $k, $attr); 59 } 60 } 61 62 mysqli_close($link); 63 print "done!"; 64?> 65--CLEAN-- 66<?php 67 require_once("clean_table.inc"); 68?> 69--EXPECTF-- 70done! 71