PropelOnDemandCollection.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. /**
  3. * This file is part of the Propel package.
  4. * For the full copyright and license information, please view the LICENSE
  5. * file that was distributed with this source code.
  6. *
  7. * @license MIT License
  8. */
  9. /**
  10. * Class for iterating over a statement and returning one Propel object at a time
  11. *
  12. * @author Francois Zaninotto
  13. * @package propel.runtime.collection
  14. */
  15. class PropelOnDemandCollection extends PropelCollection
  16. {
  17. protected
  18. $iterator,
  19. $currentRow,
  20. $currentKey = -1,
  21. $isValid = null;
  22. public function initIterator(PropelFormatter $formatter, PDOStatement $stmt)
  23. {
  24. $this->iterator = new PropelOnDemandIterator($formatter, $stmt);
  25. }
  26. // IteratorAggregate Interface
  27. public function getIterator()
  28. {
  29. return $this->iterator;
  30. }
  31. // ArrayAccess Interface
  32. public function offsetExists($offset)
  33. {
  34. if ($offset == $this->currentKey) {
  35. return true;
  36. }
  37. throw new PropelException('The On Demand Collection does not allow acces by offset');
  38. }
  39. public function offsetGet($offset)
  40. {
  41. if ($offset == $this->currentKey) {
  42. return $this->currentRow;
  43. }
  44. throw new PropelException('The On Demand Collection does not allow acces by offset');
  45. }
  46. public function offsetSet($offset, $value)
  47. {
  48. throw new PropelException('The On Demand Collection is read only');
  49. }
  50. public function offsetUnset($offset)
  51. {
  52. throw new PropelException('The On Demand Collection is read only');
  53. }
  54. // Serializable Interface
  55. public function serialize()
  56. {
  57. throw new PropelException('The On Demand Collection cannot be serialized');
  58. }
  59. public function unserialize($data)
  60. {
  61. throw new PropelException('The On Demand Collection cannot be serialized');
  62. }
  63. // Countable Interface
  64. /**
  65. * Returns the number of rows in the resultset
  66. * Warning: this number is inaccurate for most databases. Do not rely on it for a portable application.
  67. *
  68. * @return int number of results
  69. */
  70. public function count()
  71. {
  72. return $this->iterator->count();
  73. }
  74. // ArrayObject methods
  75. public function append($value)
  76. {
  77. throw new PropelException('The On Demand Collection is read only');
  78. }
  79. public function prepend($value)
  80. {
  81. throw new PropelException('The On Demand Collection is read only');
  82. }
  83. public function asort()
  84. {
  85. throw new PropelException('The On Demand Collection is read only');
  86. }
  87. public function exchangeArray($input)
  88. {
  89. throw new PropelException('The On Demand Collection is read only');
  90. }
  91. public function getArrayCopy()
  92. {
  93. throw new PropelException('The On Demand Collection does not allow acces by offset');
  94. }
  95. public function getFlags()
  96. {
  97. throw new PropelException('The On Demand Collection does not allow acces by offset');
  98. }
  99. public function ksort()
  100. {
  101. throw new PropelException('The On Demand Collection is read only');
  102. }
  103. public function natcasesort()
  104. {
  105. throw new PropelException('The On Demand Collection is read only');
  106. }
  107. public function natsort()
  108. {
  109. throw new PropelException('The On Demand Collection is read only');
  110. }
  111. public function setFlags($flags)
  112. {
  113. throw new PropelException('The On Demand Collection does not allow acces by offset');
  114. }
  115. public function uasort($cmp_function)
  116. {
  117. throw new PropelException('The On Demand Collection is read only');
  118. }
  119. public function uksort($cmp_function)
  120. {
  121. throw new PropelException('The On Demand Collection is read only');
  122. }
  123. }