1--TEST--
2Persistent connections - limits (-1, unlimited)
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--INI--
10mysqli.allow_persistent=1
11mysqli.max_persistent=-1
12mysqli.max_links=-1
13--FILE--
14<?php
15    require_once "table.inc";
16
17    if (!$res = mysqli_query($link, "SELECT 'works..' as _desc"))
18        printf("[001] Cannot run query, [%d] %s\n",
19            mysqli_errno($link), mysqli_error($link));
20
21    $row = mysqli_fetch_assoc($res);
22    mysqli_free_result($res);
23    printf("Regular connection 1 - '%s'\n", $row['_desc']);
24
25    if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
26        printf("[002] Cannot open second regular connection, [%d] %s\n",
27            mysqli_connect_errno(), mysqli_connect_error());
28
29    if (!$res = mysqli_query($link2, "SELECT 'works...' as _desc"))
30        printf("[003] Cannot run query, [%d] %s\n",
31            mysqli_errno($link2), mysqli_error($link2));
32
33    $row = mysqli_fetch_assoc($res);
34    mysqli_free_result($res);
35    printf("Regular connection 2 - '%s'\n", $row['_desc']);
36
37    $host = 'p:' . $host;
38    if (!$plink = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
39        printf("[004] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
40            $host, $user, $db, $port, $socket,
41            mysqli_connect_errno(), mysqli_connect_error());
42
43    if (!$res = mysqli_query($plink, "SELECT 'works...' as _desc"))
44        printf("[005] Cannot run query, [%d] %s\n",
45            mysqli_errno($plink), mysqli_error($plink));
46
47    $row = mysqli_fetch_assoc($res);
48    mysqli_free_result($res);
49    printf("Persistent connection 1 - '%s'\n", $row['_desc']);
50
51    if (!$plink2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
52        printf("[006] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
53            $host, $user, $db, $port, $socket,
54            mysqli_connect_errno(), mysqli_connect_error());
55
56    if (!$res = mysqli_query($plink2, "SELECT 'works...' as _desc"))
57        printf("[007] Cannot run query, [%d] %s\n",
58            mysqli_errno($plink2), mysqli_error($plink2));
59
60    $row = mysqli_fetch_assoc($res);
61    mysqli_free_result($res);
62    printf("Persistent connection 2 - '%s'\n", $row['_desc']);
63
64    $plink3 = mysqli_init();
65    if (!my_mysqli_real_connect($plink3, $host, $user, $passwd, $db, $port, $socket))
66        printf("[008] Cannot create persistent connection using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s, [%d] %s\n",
67            $host, $user, $db, $port, $socket,
68            mysqli_connect_errno(), mysqli_connect_error());
69
70    if (!$res = mysqli_query($plink3, "SELECT 'works...' as _desc"))
71        printf("[009] Cannot run query, [%d] %s\n",
72            mysqli_errno($plink2), mysqli_error($plink2));
73
74    $row = mysqli_fetch_assoc($res);
75    mysqli_free_result($res);
76    printf("Persistent connection 3 - '%s'\n", $row['_desc']);
77
78    mysqli_close($link);
79    mysqli_close($link2);
80    mysqli_close($plink);
81    mysqli_close($plink2);
82    mysqli_close($plink3);
83    print "done!";
84?>
85--CLEAN--
86<?php
87require_once "clean_table.inc";
88?>
89--EXPECT--
90Regular connection 1 - 'works..'
91Regular connection 2 - 'works...'
92Persistent connection 1 - 'works...'
93Persistent connection 2 - 'works...'
94Persistent connection 3 - 'works...'
95done!
96