1--TEST-- 2mysqli_data_seek() 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 (NULL !== ($tmp = @mysqli_data_seek())) 17 printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); 18 19 if (NULL !== ($tmp = @mysqli_data_seek($link))) 20 printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); 21 22 if (NULL !== ($tmp = @mysqli_data_seek($link, $link))) 23 printf("[003] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp); 24 25 require('table.inc'); 26 if (!$res = mysqli_query($link, 'SELECT * FROM test ORDER BY id LIMIT 4', MYSQLI_STORE_RESULT)) 27 printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 28 29 if (true !== ($tmp = mysqli_data_seek($res, 3))) 30 printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); 31 32 $row = mysqli_fetch_assoc($res); 33 if (4 != $row['id']) 34 printf("[006] Expecting record 4/d, got record %s/%s\n", $row['id'], $row['label']); 35 36 if (true !== ($tmp = mysqli_data_seek($res, 0))) 37 printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); 38 39 $row = mysqli_fetch_assoc($res); 40 if (1 != $row['id']) 41 printf("[008] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']); 42 43 if (false !== ($tmp = mysqli_data_seek($res, 4))) 44 printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); 45 46 if (false !== ($tmp = mysqli_data_seek($res, -1))) 47 printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); 48 49 mysqli_free_result($res); 50 51 if (!$res = mysqli_query($link, 'SELECT * FROM test ORDER BY id', MYSQLI_USE_RESULT)) 52 printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); 53 54 if (false !== ($tmp = mysqli_data_seek($res, 3))) 55 printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); 56 57 mysqli_free_result($res); 58 59 if (false !== ($tmp = mysqli_data_seek($res, 1))) 60 printf("[013] Expecting false, got %s/%s\n", gettype($tmp), $tmp); 61 62 mysqli_close($link); 63 64 print "done!"; 65?> 66--CLEAN-- 67<?php 68 require_once("clean_table.inc"); 69?> 70--EXPECTF-- 71Warning: mysqli_data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d 72 73Warning: mysqli_data_seek(): Couldn't fetch mysqli_result in %s on line %d 74done! 75