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