pdo_036.phpt 918 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. Testing PDORow and PDOStatement instances with Reflection
  3. --EXTENSIONS--
  4. pdo
  5. --FILE--
  6. <?php
  7. $instance = new reflectionclass('pdostatement');
  8. $x = $instance->newInstance();
  9. var_dump($x);
  10. // Allow initializing assignment.
  11. $x->queryString = "SELECT 1";
  12. var_dump($x);
  13. // But don't allow reassignment.
  14. try {
  15. $x->queryString = "SELECT 2";
  16. var_dump($x);
  17. } catch (Error $e) {
  18. echo $e->getMessage(), "\n";
  19. }
  20. $instance = new reflectionclass('pdorow');
  21. $x = $instance->newInstance();
  22. var_dump($x);
  23. ?>
  24. --EXPECTF--
  25. object(PDOStatement)#%d (0) {
  26. ["queryString"]=>
  27. uninitialized(string)
  28. }
  29. object(PDOStatement)#2 (1) {
  30. ["queryString"]=>
  31. string(8) "SELECT 1"
  32. }
  33. Property queryString is read only
  34. Fatal error: Uncaught PDOException: You may not create a PDORow manually in %spdo_036.php:%d
  35. Stack trace:
  36. #0 %spdo_036.php(%d): ReflectionClass->newInstance()
  37. #1 {main}
  38. thrown in %spdo_036.php on line %d