You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
682 B

  1. <?php
  2. class SqlResultCollection extends ArrayIterator implements iSqlResultItems
  3. {
  4. private $items;
  5. public function __construct($items)
  6. {
  7. $this->items = $items;
  8. foreach ($items as $item) {
  9. parent::append($item);
  10. }
  11. }
  12. /**
  13. * @return DbStatement[]
  14. */
  15. public function fetchAll()
  16. {
  17. return (array) $this;
  18. }
  19. /**
  20. * @param $field
  21. * @return mixed
  22. */
  23. public function fetchField($field)
  24. {
  25. $item = $this->offsetGet(0);
  26. return $item->{$field};
  27. }
  28. /**
  29. * @return mixed
  30. */
  31. public function fetch()
  32. {
  33. return $this->offsetGet(0);
  34. }
  35. }