conn_attr_2.phpt 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. --TEST--
  2. Set and get of connection attributes across persistent connections and sysdba connection.
  3. --EXTENSIONS--
  4. oci8
  5. --SKIPIF--
  6. <?php
  7. if (getenv('SKIP_REPEAT')) die('skip fails with repeat');
  8. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  9. require(__DIR__.'/skipif.inc');
  10. if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
  11. if ($test_drcp) die("skip output might vary with DRCP");
  12. preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
  13. if (!(isset($matches[0]) && $matches[1] >= 10)) {
  14. die("skip expected output only valid when using Oracle 10g or greater database server");
  15. }
  16. ?>
  17. --INI--
  18. oci8.privileged_connect = On
  19. --FILE--
  20. <?php
  21. $testuser = 'testuser_attr_2'; // Used in conn_attr.inc
  22. $testpassword = 'testuser';
  23. require(__DIR__."/conn_attr.inc");
  24. $attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER');
  25. echo"**Set values using pconnect-1**\n";
  26. var_dump($pc1 = oci_pconnect($testuser,$testpassword,$dbase));
  27. foreach($attr_array as $attr) {
  28. set_attr($pc1,$attr,100);
  29. }
  30. // using pc1 again
  31. echo"\n**Get values using pconnect-2**\n";
  32. var_dump($pc3 = oci_pconnect($testuser,$testpassword,$dbase));
  33. foreach($attr_array as $attr) {
  34. get_attr($pc3,$attr);
  35. }
  36. // Get with different pconnect
  37. echo"\n**Get values using pconnect-3**\n";
  38. var_dump($pc2 = oci_pconnect($testuser,$testpassword,$dbase,'UTF8'));
  39. foreach($attr_array as $attr) {
  40. get_attr($pc2,$attr);
  41. }
  42. oci_close($pc1);
  43. oci_close($pc2);
  44. oci_close($pc3);
  45. // Re-open a persistent connection and check for the attr values.
  46. echo "\n**Re-open a pconnect()**\n";
  47. var_dump($pc4 = oci_pconnect($testuser,$testpassword,$dbase));
  48. foreach($attr_array as $attr) {
  49. get_attr($pc4,$attr);
  50. }
  51. oci_close($pc4);
  52. // Test with SYSDBA connection.
  53. echo "\n**Test with SYSDBA connection**\n";
  54. $sys_c1 = @oci_pconnect($testuser,$testpassword,$dbase,false,OCI_SYSDBA);
  55. var_dump($sys_c1);
  56. if (!$sys_c1) {
  57. $e = oci_error();
  58. if ($e['code'] != 1031 && $e['code'] != 1017) {
  59. var_dump($e);
  60. }
  61. } else {
  62. set_attr($sys_c1,'ACTION',10);
  63. get_sys_attr($sys_c1,'ACTION');
  64. get_attr($sys_c1,'ACTION');
  65. oci_close($sys_c1);
  66. }
  67. clean_up($c);
  68. echo "Done\n";
  69. ?>
  70. --EXPECTF--
  71. **Set values using pconnect-1**
  72. resource(%d) of type (oci8 persistent connection)
  73. Value of MODULE has been set successfully
  74. Value of ACTION has been set successfully
  75. Value of CLIENT_INFO has been set successfully
  76. Value of CLIENT_IDENTIFIER has been set successfully
  77. **Get values using pconnect-2**
  78. resource(%d) of type (oci8 persistent connection)
  79. The value of MODULE is PHP TEST100
  80. The value of ACTION is TASK100
  81. The value of CLIENT_INFO is INFO1100
  82. The value of CLIENT_IDENTIFIER is ID00100
  83. **Get values using pconnect-3**
  84. resource(%d) of type (oci8 persistent connection)
  85. The value of MODULE is %s
  86. The value of ACTION is
  87. The value of CLIENT_INFO is
  88. The value of CLIENT_IDENTIFIER is
  89. **Re-open a pconnect()**
  90. resource(%d) of type (oci8 persistent connection)
  91. The value of MODULE is PHP TEST100
  92. The value of ACTION is TASK100
  93. The value of CLIENT_INFO is INFO1100
  94. The value of CLIENT_IDENTIFIER is ID00100
  95. **Test with SYSDBA connection**
  96. bool(false)
  97. Done