mysqli_pconn_conn_multiple.phpt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. --TEST--
  2. Calling connect() on an open persistent connection to create a new persistent connection
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifemb.inc');
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --INI--
  10. mysqli.allow_persistent=1
  11. mysqli.max_persistent=-1
  12. mysqli.max_links=-1
  13. --FILE--
  14. <?php
  15. require_once("connect.inc");
  16. $phost = 'p:' . $host;
  17. if (!$link = my_mysqli_connect($phost, $user, $passwd, $db, $port, $socket))
  18. printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  19. $phost, $user, $db, $port, $socket);
  20. if (!$thread_id = $link->thread_id)
  21. printf("[002] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  22. if (true !== ($tmp = my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
  23. printf("[003] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
  24. if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0))
  25. printf("[004] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
  26. if ($thread_id == $new_thread_id)
  27. printf("[005] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
  28. if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) ||
  29. !($row = mysqli_fetch_assoc($res)))
  30. printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  31. var_dump($row);
  32. mysqli_free_result($res);
  33. mysqli_close($link);
  34. if (!$link = new my_mysqli($phost, $user, $passwd, $db, $port, $socket))
  35. printf("[007] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  36. $phost, $user, $db, $port, $socket);
  37. if (!$thread_id = $link->thread_id)
  38. printf("[008] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  39. if (true !== ($tmp = $link->real_connect($host, $user, $passwd, $db, $port, $socket)))
  40. printf("[009] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
  41. if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0))
  42. printf("[010] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
  43. if ($thread_id == $new_thread_id)
  44. printf("[011] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
  45. if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) ||
  46. !($row = $res->fetch_assoc()))
  47. printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  48. var_dump($row);
  49. mysqli_free_result($res);
  50. mysqli_close($link);
  51. if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket)))
  52. printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
  53. if (!$link = mysqli_connect($phost, $user, $passwd, $db, $port, $socket))
  54. printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  55. $phost, $user, $db, $port, $socket);
  56. if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
  57. printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
  58. printf("Flipping phost/host order\n");
  59. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  60. printf("[016] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  61. $host, $user, $db, $port, $socket);
  62. if (!$thread_id = mysqli_thread_id($link))
  63. printf("[017] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  64. if (true !== ($tmp = my_mysqli_real_connect($link, $phost, $user, $passwd, $db, $port, $socket)))
  65. printf("[018] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
  66. if (!is_int($new_thread_id = mysqli_thread_id($link)) || ($new_thread_id < 0))
  67. printf("[019] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
  68. if ($thread_id == $new_thread_id)
  69. printf("[020] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
  70. if (!($res = mysqli_query($link, "SELECT 'ok' AS it_works")) ||
  71. !($row = mysqli_fetch_assoc($res)))
  72. printf("[021] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  73. var_dump($row);
  74. mysqli_free_result($res);
  75. mysqli_close($link);
  76. if (!$link = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
  77. printf("[022] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  78. $host, $user, $db, $port, $socket);
  79. if (!$thread_id = $link->thread_id)
  80. printf("[023] Cannot determine thread id, test will fail, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  81. if (true !== ($tmp = $link->real_connect($phost, $user, $passwd, $db, $port, $socket)))
  82. printf("[024] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
  83. if (!is_int($new_thread_id = $link->thread_id) || ($new_thread_id < 0))
  84. printf("[025] Expecting int/any got %s/%s\n", gettype($tmp), $tmp);
  85. if ($thread_id == $new_thread_id)
  86. printf("[026] Expecting new connection and new thread id. Old thread id %d, new thread id %d\n", $thread_id, $new_thread_id);
  87. if (!($res = $link->query("SELECT 'works also with oo' AS syntax")) ||
  88. !($row = $res->fetch_assoc()))
  89. printf("[027] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  90. var_dump($row);
  91. mysqli_free_result($res);
  92. mysqli_close($link);
  93. if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
  94. printf("[028] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
  95. if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  96. printf("[029] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  97. $host, $user, $db, $port, $socket);
  98. if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket)))
  99. printf("[030] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
  100. print "done!";
  101. ?>
  102. --EXPECTF--
  103. array(1) {
  104. [%u|b%"it_works"]=>
  105. %unicode|string%(2) "ok"
  106. }
  107. array(1) {
  108. [%u|b%"syntax"]=>
  109. %unicode|string%(18) "works also with oo"
  110. }
  111. Flipping phost/host order
  112. array(1) {
  113. [%u|b%"it_works"]=>
  114. %unicode|string%(2) "ok"
  115. }
  116. array(1) {
  117. [%u|b%"syntax"]=>
  118. %unicode|string%(18) "works also with oo"
  119. }
  120. done!