error_bind_2.phpt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. --TEST--
  2. Test some more oci_bind_by_name error conditions
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('oci8')) die ("skip no oci8 extension");
  6. $target_dbs = array('oracledb' => true, 'timesten' => true); // test runs on these DBs
  7. require(dirname(__FILE__).'/skipif.inc');
  8. preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
  9. if (!(isset($matches[0]) && $matches[1] >= 12)) {
  10. die("skip expected output only valid when using Oracle Database 12c or greater");
  11. }
  12. preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
  13. if (!(isset($matches[0]) && $matches[0] >= 12)) {
  14. die("skip works only with Oracle 12c or greater version of Oracle client libraries");
  15. }
  16. ?>
  17. --FILE--
  18. <?php
  19. require(dirname(__FILE__).'/connect.inc');
  20. // Initialization
  21. $stmtarray = array(
  22. "drop table error_bind_2_tab",
  23. "create table error_bind_2_tab(name varchar(10))"
  24. );
  25. oci8_test_sql_execute($c, $stmtarray);
  26. echo "Test 1 - SQLT_BOL\n";
  27. unset($name);
  28. $stmt = oci_parse($c, "insert into error_bind_2_tab values (:name)");
  29. oci_bind_by_name($stmt, ":name", $name, -1, SQLT_BOL);
  30. $name=$c;
  31. var_dump(oci_execute($stmt));
  32. echo "Test 2 - SQLT_BOL\n";
  33. unset($name);
  34. $stmt = oci_parse($c, "insert into error_bind_2_tab values (:name)");
  35. $name=$c;
  36. oci_bind_by_name($stmt, ":name", $name, -1, SQLT_BOL);
  37. // Clean up
  38. $stmtarray = array(
  39. "drop table error_bind_2_tab",
  40. );
  41. oci8_test_sql_execute($c, $stmtarray);
  42. echo "Done\n";
  43. ?>
  44. --EXPECTF--
  45. Test 1 - SQLT_BOL
  46. Warning: oci_execute(): Invalid variable used for bind in %s on line %d
  47. bool(false)
  48. Test 2 - SQLT_BOL
  49. Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
  50. Done