error_bind.phpt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. --TEST--
  2. Test some oci_bind_by_name error conditions
  3. --EXTENSIONS--
  4. oci8
  5. --FILE--
  6. <?php
  7. require(__DIR__.'/connect.inc');
  8. $drop = "drop table bind_test";
  9. $statement = oci_parse($c, $drop);
  10. @oci_execute($statement);
  11. $create = "create table bind_test(name varchar(10))";
  12. $statement = oci_parse($c, $create);
  13. oci_execute($statement);
  14. echo "Insert value\n";
  15. $name = 'abc';
  16. $stmt = oci_parse($c, "insert into bind_test values (:name)");
  17. oci_bind_by_name($stmt, ":name", $name, 10, SQLT_CHR);
  18. var_dump(oci_execute($stmt));
  19. echo "Test 1 - Assign a resource to the bind variable and execute\n";
  20. $name=$c;
  21. var_dump(oci_execute($stmt));
  22. echo "Test 2 - Re-bind a resource\n";
  23. oci_bind_by_name($stmt, ":name", $c);
  24. var_dump(oci_execute($stmt));
  25. var_dump($c);
  26. // Use a connection resource instead of a ROWID.
  27. echo "Test 3 - Resource mismatch !!\n";
  28. $stmt = oci_parse($c, "update bind_test set name='xyz' returning rowid into :r_id");
  29. oci_bind_by_name($stmt, ":r_id", $c);
  30. var_dump(oci_execute($stmt));
  31. // Clean up
  32. $drop = "drop table bind_test";
  33. $statement = oci_parse($c, $drop);
  34. @oci_execute($statement);
  35. echo "Done\n";
  36. ?>
  37. --EXPECTF--
  38. Insert value
  39. bool(true)
  40. Test 1 - Assign a resource to the bind variable and execute
  41. Warning: oci_execute(): Invalid variable used for bind in %s on line %d
  42. bool(false)
  43. Test 2 - Re-bind a resource
  44. Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
  45. Warning: oci_execute(): Invalid variable used for bind in %s on line %d
  46. bool(false)
  47. resource(%d) of type (oci8 connection)
  48. Test 3 - Resource mismatch !!
  49. Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
  50. Warning: oci_execute(): ORA-%r(01008|57000)%r: %s on line %d
  51. bool(false)
  52. Done