pdo_035.phpt 873 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. PDO Common: PDORow + get_parent_class()
  3. --EXTENSIONS--
  4. pdo_sqlite
  5. --FILE--
  6. <?php
  7. $db = new PDO('sqlite::memory:');
  8. $db->exec('CREATE TABLE test (id int)');
  9. $db->exec('INSERT INTO test VALUES (23)');
  10. $stmt = $db->prepare('SELECT id FROM test');
  11. $stmt->execute();
  12. $result = $stmt->fetch(PDO::FETCH_LAZY);
  13. echo get_class($result), "\n";
  14. var_dump(get_parent_class($result));
  15. try {
  16. $result->foo = 1;
  17. } catch (Error $e) {
  18. echo $e->getMessage(), "\n";
  19. }
  20. try {
  21. $result[0] = 1;
  22. } catch (Error $e) {
  23. echo $e->getMessage(), "\n";
  24. }
  25. try {
  26. unset($result->foo);
  27. } catch (Error $e) {
  28. echo $e->getMessage(), "\n";
  29. }
  30. try {
  31. unset($result[0]);
  32. } catch (Error $e) {
  33. echo $e->getMessage(), "\n";
  34. }
  35. ?>
  36. --EXPECT--
  37. PDORow
  38. bool(false)
  39. Cannot write to PDORow property
  40. Cannot write to PDORow offset
  41. Cannot unset PDORow property
  42. Cannot unset PDORow offset