1--TEST--
2mysql_pconnect() - disabling feature
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--INI--
9mysql.allow_persistent=1
10mysql.max_persistent=1
11mysql.max_links=2
12--FILE--
13<?php
14	require_once("connect.inc");
15	require_once("table.inc");
16	mysql_close($link);
17
18	if ($socket)
19		$myhost = sprintf("%s:%s", $host, $socket);
20	else if ($port)
21		$myhost = sprintf("%s:%s", $host, $port);
22	else
23	$myhost = $host;
24
25	if (($plink = mysql_pconnect($myhost, $user, $passwd)))
26		printf("[001] Can connect to the server.\n");
27
28	if ((mysql_select_db($db, $plink)) &&
29			($res = mysql_query('SELECT id FROM test', $plink)) &&
30			($row = mysql_fetch_assoc($res)) &&
31			(mysql_free_result($res))) {
32		printf("[002] Can fetch data using persistent connection! Data = '%s'\n",
33			$row['id']);
34	} else {
35		printf("[002] [%d] %s\n", mysql_errno($plink), mysql_error($plink));
36	}
37
38	$thread_id = mysql_thread_id($plink);
39	mysql_close($plink);
40
41	if (!($plink = mysql_pconnect($myhost, $user, $passwd)))
42		printf("[003] Cannot connect, [%d] %s\n", mysql_errno(), mysql_error());
43
44	if (mysql_thread_id($plink) != $thread_id)
45		printf("[004] Looks like the second call to pconnect() did not give us the same connection.\n");
46
47	$thread_id = mysql_thread_id($plink);
48	mysql_close($plink);
49
50	if (!($plink = mysql_connect($myhost, $user, $passwd, true)))
51		printf("[005] Cannot connect, [%d] %s\n", mysql_errno(), mysql_error());
52
53	if (mysql_thread_id($plink) == $thread_id)
54		printf("[006] Looks like connect() did not return a new connection.\n");
55
56	if (($link = mysql_connect($myhost, $user, $passwd, true)))
57		printf("[007] Can connect although limit has been reached, [%d] %s\n", mysql_errno(), mysql_error());
58
59	print "done!";
60?>
61--EXPECTF--
62Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
63
64Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
65[001] Can connect to the server.
66[002] Can fetch data using persistent connection! Data = '1'
67
68Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
69
70Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
71
72Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
73
74Warning: mysql_connect(): Too many open links (2) in %s on line %d
75done!
76