xref: /PHP-7.1/ext/mysqli/tests/001.phpt (revision 113213f0)
1--TEST--
2mysqli connect
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	$test = "";
14
15	/*** test mysqli_connect localhost:port ***/
16	$link = my_mysqli_connect($host, $user, $passwd, "", $port, $socket);
17	$test .= ($link) ? "1" : "0";
18	mysqli_close($link);
19
20	/*** test mysqli_real_connect ***/
21	$link = mysqli_init();
22	$test.= (my_mysqli_real_connect($link, $host, $user, $passwd, "", $port, $socket) )
23		? "1" : "0";
24	mysqli_close($link);
25
26	/*** test mysqli_real_connect with db ***/
27	$link = mysqli_init();
28	$test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
29		? "1" : "0";
30	mysqli_close($link);
31
32	/*** test mysqli_real_connect with port ***/
33	$link = mysqli_init();
34	$test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
35		? "1":"0";
36	mysqli_close($link);
37
38	/* temporary addition for Kent's setup, Win32 box */
39	for ($i = 0; $i < 10; $i++) {
40		if (!$link = mysqli_init())
41			printf("[001 + %d] mysqli_init() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());
42
43		if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
44			printf("[002 + %d] mysqli_real_connect() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());
45
46		mysqli_close($link);
47	}
48
49	/*** test mysqli_real_connect compressed ***/
50	/*
51	$link = mysqli_init();
52	$test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_COMPRESS))
53		? "1" : "0";
54	mysqli_close($link);
55  */
56	/* todo ssl connections */
57
58	var_dump($test);
59	print "done!";
60?>
61--EXPECTF--
62%s(4) "1111"
63done!
64