1--TEST--
2mysqli_stmt_prepare()
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	// Note: No SQL tests here! We can expand one of the *fetch()
14	// tests to a generic SQL test, if we ever need that.
15	// We would duplicate the SQL test cases if we have it here and in one of the
16	// fetch tests, because the fetch tests would have to call prepare/execute etc.
17	// anyway.
18
19	$tmp    = NULL;
20	$link   = NULL;
21
22	if (!is_null($tmp = @mysqli_stmt_prepare()))
23		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
24
25	if (!is_null($tmp = @mysqli_stmt_prepare($link)))
26		printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
27
28	require('table.inc');
29
30	if (!$stmt = mysqli_stmt_init($link))
31		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
32
33	if (NULL !== ($tmp = @mysqli_stmt_prepare($stmt)))
34		printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
35
36	if (false !== ($tmp = mysqli_stmt_prepare($stmt, '')))
37		printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
38
39	if (true !== ($tmp = mysqli_stmt_prepare($stmt, 'SELECT id FROM test')))
40		printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
41
42	mysqli_stmt_close($stmt);
43
44	if (NULL !== ($tmp = mysqli_stmt_prepare($stmt, "SELECT id FROM test")))
45		printf("[007] Expecting NULL, got %s/%s\n");
46
47	mysqli_close($link);
48	print "done!";
49?>
50--CLEAN--
51<?php
52	require_once("clean_table.inc");
53?>
54--EXPECTF--
55Warning: mysqli_stmt_prepare(): Couldn't fetch mysqli_stmt in %s on line %d
56done!
57