connect_scope1.phpt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. --TEST--
  2. Test oci_connect end-of-scope when statement returned
  3. --EXTENSIONS--
  4. oci8
  5. --FILE--
  6. <?php
  7. require(__DIR__.'/details.inc');
  8. // Initialization
  9. $stmtarray = array(
  10. "drop table connect_scope1_tab",
  11. "create table connect_scope1_tab (c1 number)",
  12. );
  13. if (!empty($dbase))
  14. $c1 = oci_new_connect($user,$password,$dbase);
  15. else
  16. $c1 = oci_new_connect($user,$password);
  17. oci8_test_sql_execute($c1, $stmtarray);
  18. // Run Test
  19. echo "Test 1 - oci_connect\n";
  20. function f()
  21. {
  22. global $user, $password, $dbase;
  23. if (!empty($dbase))
  24. $c = oci_connect($user,$password,$dbase);
  25. else
  26. $c = oci_connect($user,$password);
  27. $s = oci_parse($c, "insert into connect_scope1_tab values (1)");
  28. oci_execute($s, OCI_DEFAULT); // no commit
  29. return($s); // this keeps the connection refcount positive so the connection isn't closed
  30. }
  31. $s2 = f();
  32. // Check nothing committed yet
  33. $s1 = oci_parse($c1, "select * from connect_scope1_tab");
  34. oci_execute($s1, OCI_DEFAULT);
  35. oci_fetch_all($s1, $r);
  36. var_dump($r);
  37. // insert 2nd row on returned statement, committing both rows
  38. oci_execute($s2);
  39. // Verify data was committed
  40. $s1 = oci_parse($c1, "select * from connect_scope1_tab");
  41. oci_execute($s1);
  42. oci_fetch_all($s1, $r);
  43. var_dump($r);
  44. // Cleanup
  45. $stmtarray = array(
  46. "drop table connect_scope1_tab"
  47. );
  48. oci8_test_sql_execute($c1, $stmtarray);
  49. echo "Done\n";
  50. ?>
  51. --EXPECT--
  52. Test 1 - oci_connect
  53. array(1) {
  54. ["C1"]=>
  55. array(0) {
  56. }
  57. }
  58. array(1) {
  59. ["C1"]=>
  60. array(2) {
  61. [0]=>
  62. string(1) "1"
  63. [1]=>
  64. string(1) "1"
  65. }
  66. }
  67. Done