mysqli_max_links.phpt 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. --TEST--
  2. Testing mysqli.max_links
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifemb.inc');
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --INI--
  10. mysqli.max_links=1
  11. --FILE--
  12. <?php
  13. require_once("connect.inc");
  14. require_once("table.inc");
  15. // to make sure we have at least one working connection...
  16. var_dump(mysqli_ping($link));
  17. // to make sure that max_links is really set to one
  18. var_dump((int)ini_get('mysqli.max_links'));
  19. $links = array();
  20. for ($i = 1; $i <= 5; $i++)
  21. if ($links[$i] = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  22. printf("[%03d] One link is already open, it should not be possible to open more, [%d] %s, [%d] %s\n",
  23. $i, mysqli_connect_errno(), mysqli_connect_error(),
  24. mysqli_errno($links[$i]), mysqli_error($links[$i]));
  25. for ($i = 1; $i <= 5; $i++) {
  26. if ($res = mysqli_query($links[$i], 'SELECT id FROM test LIMIT 1')) {
  27. printf("[%03d] Can run query on link %d\n", 5 + $i, $i);
  28. mysqli_free_result($res);
  29. }
  30. mysqli_close($links[$i]);
  31. }
  32. mysqli_close($link);
  33. print "done!";
  34. ?>
  35. --CLEAN--
  36. <?php
  37. require_once("clean_table.inc");
  38. ?>
  39. --EXPECTF--
  40. bool(true)
  41. int(1)
  42. Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
  43. Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
  44. Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
  45. Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
  46. Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d
  47. Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d
  48. Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in %s on line %d
  49. Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d
  50. Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in %s on line %d
  51. Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d
  52. Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in %s on line %d
  53. Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d
  54. Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in %s on line %d
  55. Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d
  56. Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in %s on line %d
  57. done!