drcp_connect1.phpt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. --TEST--
  2. DRCP: oci_connect()
  3. --EXTENSIONS--
  4. oci8
  5. --SKIPIF--
  6. <?php
  7. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs (Calling PL/SQL from SQL is not supported in TimesTen)
  8. require(__DIR__.'/skipif.inc');
  9. ?>
  10. --INI--
  11. oci8.connection_class=test
  12. oci8.old_oci_close_semantics=0
  13. --FILE--
  14. <?php
  15. require __DIR__."/details.inc";
  16. require __DIR__."/drcp_functions.inc";
  17. // Open a number of connections with oci_connect and oci_pconnect and verify
  18. // whether we get a used session with DRCP.
  19. // To verify this, we change the value of a PL/SQL package variable in one
  20. // session and query for this through another connection
  21. echo "Test 1a\n";
  22. var_dump($conn1 = oci_connect($user,$password,$dbase));
  23. // Create the package
  24. drcp_create_package($conn1);
  25. echo "Test 1b\n";
  26. // OCI_CONNECT
  27. echo " This is with OCI_CONNECT.....\n";
  28. drcp_select_packagevar($conn1); // Returns 0
  29. drcp_set_packagevar($conn1,1000);
  30. oci_close($conn1);
  31. echo " Connection conn1 closed....\n";
  32. echo "Test 2\n";
  33. // Second connection should return 0 for the package variable.
  34. var_dump($conn2 = oci_connect($user,$password,$dbase));
  35. echo " Select with connection 2\n";
  36. drcp_select_packagevar($conn2); // Returns 0
  37. drcp_set_packagevar($conn2,100);
  38. echo "Test 3\n";
  39. // Third connection. There is no oci_close() for conn2 hence this should
  40. // return the value set by conn2.
  41. var_dump($conn3 = oci_connect($user,$password,$dbase));
  42. echo " Select with connection 3\n";
  43. drcp_select_packagevar($conn3); // Returns 100
  44. // Close all the connections
  45. oci_close($conn2);
  46. oci_close($conn3);
  47. echo "Test 4\n";
  48. // OCI_PCONNECT
  49. echo " This is with oci_pconnect().....\n";
  50. var_dump($pconn1 = oci_pconnect($user,$password,$dbase));
  51. drcp_set_packagevar($pconn1,1000);
  52. oci_close($pconn1);
  53. echo " Connection pconn1 closed....\n";
  54. // Second connection with oci_pconnect should return the same session hence the
  55. // value returned is what is set by pconn1
  56. echo "Test 5\n";
  57. var_dump($pconn2 = oci_pconnect($user,$password,$dbase));
  58. echo " Select with persistent connection 2\n";
  59. drcp_select_packagevar($pconn2); // Returns 1000
  60. oci_close($pconn2);
  61. echo "Done\n";
  62. ?>
  63. --EXPECTF--
  64. Test 1a
  65. resource(%d) of type (oci8 connection)
  66. Test 1b
  67. This is with OCI_CONNECT.....
  68. The value of the package variable is 0
  69. Package variable value set to 1000
  70. Connection conn1 closed....
  71. Test 2
  72. resource(%d) of type (oci8 connection)
  73. Select with connection 2
  74. The value of the package variable is 0
  75. Package variable value set to 100
  76. Test 3
  77. resource(%d) of type (oci8 connection)
  78. Select with connection 3
  79. The value of the package variable is 100
  80. Test 4
  81. This is with oci_pconnect().....
  82. resource(%d) of type (oci8 persistent connection)
  83. Package variable value set to 1000
  84. Connection pconn1 closed....
  85. Test 5
  86. resource(%d) of type (oci8 persistent connection)
  87. Select with persistent connection 2
  88. The value of the package variable is 1000
  89. Done