drcp_scope2.phpt 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. --TEST--
  2. DRCP: oci_new_connect() and oci_connect with scope end when oci8.old_oci_close_semantics OFF
  3. --EXTENSIONS--
  4. oci8
  5. --INI--
  6. oci8.old_oci_close_semantics=0
  7. --FILE--
  8. <?php
  9. require __DIR__."/drcp_functions.inc";
  10. require __DIR__."/details.inc";
  11. // Scope considered here is the functional scope
  12. // Test will open a connection within a function (function 1).
  13. // Update a table
  14. // Open another connection from function 2.
  15. // When the scope ends the txn is rolled back and hence the updated value
  16. // will not be reflected for oci_connect and oci_new_connect.
  17. // Create the table
  18. $c = oci_new_connect($user,$password,$dbase);
  19. @drcp_drop_table($c);
  20. drcp_create_table($c);
  21. // OCI_NEW_CONNECT
  22. $conn_type = 1;
  23. echo "This is with a OCI_NEW_CONNECT\n";
  24. function1($user,$password,$dbase,$conn_type);
  25. // Should return the OLD value
  26. function2($user,$password,$dbase,$conn_type);
  27. // OCI_CONNECT
  28. $conn_type = 2;
  29. echo "\n\nThis is with a OCI_CONNECT\n";
  30. function1($user,$password,$dbase,$conn_type);
  31. // Should return the OLD value
  32. function2($user,$password,$dbase,$conn_type);
  33. //This is the first scope for the script
  34. function function1($user,$password,$dbase,$conn_type)
  35. {
  36. switch($conn_type)
  37. {
  38. case 1:
  39. var_dump($conn1 = oci_new_connect($user,$password,$dbase));
  40. break;
  41. case 2:
  42. var_dump($conn1 = oci_connect($user,$password,$dbase));
  43. break;
  44. }
  45. drcp_update_table($conn1);
  46. }
  47. // This is the second scope
  48. function function2($user,$password,$dbase,$conn_type)
  49. {
  50. switch($conn_type)
  51. {
  52. case 1:
  53. var_dump($conn1 = oci_new_connect($user,$password,$dbase));
  54. break;
  55. case 2:
  56. var_dump($conn1 = oci_connect($user,$password,$dbase));
  57. break;
  58. }
  59. drcp_select_value($conn1);
  60. }
  61. drcp_drop_table($c);
  62. oci_close($c);
  63. echo "Done\n";
  64. ?>
  65. --EXPECTF--
  66. This is with a OCI_NEW_CONNECT
  67. resource(%d) of type (oci8 connection)
  68. Update done-- DEPT value has been set to NEWDEPT
  69. resource(%d) of type (oci8 connection)
  70. The value of DEPT for id 105 is HR
  71. This is with a OCI_CONNECT
  72. resource(%d) of type (oci8 connection)
  73. Update done-- DEPT value has been set to NEWDEPT
  74. resource(%d) of type (oci8 connection)
  75. The value of DEPT for id 105 is HR
  76. Done