Annotation of embedaddon/php/ext/mysqli/tests/mysqli_stmt_field_count.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: mysqli_stmt_field_counts()
! 3: --SKIPIF--
! 4: <?php
! 5: require_once('skipif.inc');
! 6: require_once('skipifemb.inc');
! 7: require_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_field_count()))
! 17: printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
! 18:
! 19: if (!is_null($tmp = @mysqli_stmt_field_count($link)))
! 20: printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
! 21:
! 22: require('table.inc');
! 23:
! 24: $stmt = mysqli_stmt_init($link);
! 25: if (!is_null($tmp = mysqli_stmt_field_count($stmt)))
! 26: printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
! 27:
! 28: if (mysqli_stmt_prepare($stmt, ''))
! 29: printf("[004] Prepare should fail for an empty statement\n");
! 30: if (!is_null($tmp = mysqli_stmt_field_count($stmt)))
! 31: printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
! 32:
! 33: if (!mysqli_stmt_prepare($stmt, 'SELECT 1'))
! 34: printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 35: if (1 !== ($tmp = mysqli_stmt_field_count($stmt)))
! 36: printf("[007] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
! 37:
! 38: if (!mysqli_stmt_prepare($stmt, 'SELECT 1, 2'))
! 39: printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 40: if (2 !== ($tmp = mysqli_stmt_field_count($stmt)))
! 41: printf("[009] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp);
! 42:
! 43: if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test'))
! 44: printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 45: if (2 !== ($tmp = mysqli_stmt_field_count($stmt)))
! 46: printf("[011] Expecting int/2, got %s/%s\n", gettype($tmp), $tmp);
! 47:
! 48: if (!mysqli_stmt_prepare($stmt, 'SELECT label FROM test') ||
! 49: !mysqli_stmt_execute($stmt))
! 50: printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 51: if (1 !== ($tmp = mysqli_stmt_field_count($stmt)))
! 52: printf("[013] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
! 53:
! 54: $label = null;
! 55: if (mysqli_stmt_bind_param($stmt, "s", $label))
! 56: printf("[014] expected error - got ok\n");
! 57: while (mysqli_stmt_fetch($stmt))
! 58: if (1 !== ($tmp = mysqli_stmt_field_count($stmt)))
! 59: printf("[015] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
! 60:
! 61: if (!mysqli_stmt_prepare($stmt, 'INSERT INTO test(id) VALUES (100)'))
! 62: printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 63: if (0 !== ($tmp = mysqli_stmt_field_count($stmt)))
! 64: printf("[017] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
! 65:
! 66: if (!mysqli_stmt_prepare($stmt, "UPDATE test SET label = 'z' WHERE id = 1") ||
! 67: !mysqli_stmt_execute($stmt))
! 68: printf("[018] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
! 69:
! 70: if (0 !== ($tmp = mysqli_stmt_field_count($stmt)))
! 71: printf("[019] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
! 72:
! 73: mysqli_stmt_close($stmt);
! 74:
! 75: if (mysqli_stmt_prepare($stmt, 'SELECT id FROM test'))
! 76: printf("[020] Prepare should fail, statement has been closed\n");
! 77: if (!is_null($tmp = mysqli_stmt_field_count($stmt)))
! 78: printf("[011] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
! 79:
! 80: mysqli_close($link);
! 81:
! 82: print "done!";
! 83: ?>
! 84: --CLEAN--
! 85: <?php
! 86: require_once("clean_table.inc");
! 87: ?>
! 88: --EXPECTF--
! 89: Warning: mysqli_stmt_field_count(): invalid object or resource mysqli_stmt
! 90: in %s on line %d
! 91:
! 92: Warning: mysqli_stmt_field_count(): invalid object or resource mysqli_stmt
! 93: in %s on line %d
! 94:
! 95: Warning: mysqli_stmt_bind_param(): Number of variables doesn't match number of parameters in prepared statement in %s on line %d
! 96:
! 97: Warning: mysqli_stmt_prepare(): Couldn't fetch mysqli_stmt in %s on line %d
! 98:
! 99: Warning: mysqli_stmt_field_count(): Couldn't fetch mysqli_stmt in %s on line %d
! 100: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>