mysql_pconnect.phpt 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. --TEST--
  2. mysql_pconnect()
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifconnectfailure.inc');
  7. ?>
  8. --INI--
  9. mysql.max_persistent=10
  10. mysql.allow_persistent=1
  11. --FILE--
  12. <?php
  13. include "connect.inc";
  14. $tmp = NULL;
  15. $link = NULL;
  16. // mysql_pconnect ( [string server [, string username [, string password [, bool new_link [, int client_flags]]]]] )
  17. if (NULL !== ($tmp = @mysql_pconnect($link, $link, $link, $link, $link, $link)))
  18. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  19. $myhost = (is_null($socket)) ? ((is_null($port)) ? $host : $host . ':' . $port) : $host . ':' . $socket;
  20. if (!$link = mysql_pconnect($myhost, $user, $passwd, true))
  21. printf("[002] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  22. $host, $myhost, $user, $db, $port, $socket);
  23. mysql_close($link);
  24. if ($link = mysql_pconnect($myhost, $user . 'unknown_really', $passwd . 'non_empty', true))
  25. printf("[003] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
  26. $host, $myhost, $user . 'unknown_really', $db, $port, $socket);
  27. if (false !== $link)
  28. printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
  29. // Run the following tests without an anoynmous MySQL user and use a password for the test user!
  30. if (!ini_get('sql.safe_mode')) {
  31. if ($socket) {
  32. ini_set('mysql.default_socket', $socket);
  33. if (!is_resource($link = mysql_pconnect($host, $user, $passwd, true))) {
  34. printf("[005] Usage of mysql.default_socket failed\n") ;
  35. } else {
  36. mysql_close($link);
  37. }
  38. } else {
  39. ini_set('mysql.default_socket', null);
  40. }
  41. ini_set('mysql.default_port', $port);
  42. if (!is_resource($link = mysql_pconnect($host, $user, $passwd, true))) {
  43. printf("[006] Usage of mysql.default_port failed\n") ;
  44. } else {
  45. mysql_close($link);
  46. }
  47. ini_set('mysql.default_password', $passwd);
  48. if (!is_resource($link = mysql_pconnect($myhost, $user))) {
  49. printf("[007] Usage of mysql.default_password failed\n") ;
  50. } else {
  51. mysql_close($link);
  52. }
  53. ini_set('mysql.default_user', $user);
  54. if (!is_resource($link = mysql_pconnect($myhost))) {
  55. printf("[008] Usage of mysql.default_user failed\n");
  56. } else {
  57. mysql_close($link);
  58. }
  59. ini_set('mysql.default_host', $myhost);
  60. if (!is_resource($link = mysql_pconnect())) {
  61. printf("[009] Usage of mysql.default_host failed\n") ;
  62. } else {
  63. mysql_close($link);
  64. }
  65. }
  66. print "done!";
  67. ?>
  68. --EXPECTF--
  69. Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
  70. Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
  71. Warning: mysql_pconnect(): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d
  72. Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
  73. Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
  74. Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
  75. Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
  76. done!