Result.php 885 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * Lithium: the most rad php framework
  4. *
  5. * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
  6. * @license http://opensource.org/licenses/bsd-license.php The BSD License
  7. */
  8. namespace lithium\data\source\mongo_db;
  9. use MongoGridFSFile;
  10. class Result extends \lithium\data\source\Result {
  11. /**
  12. * Fetches the result from the resource and caches it.
  13. *
  14. * @return boolean Return `true` on success or `false` if it is not valid.
  15. */
  16. protected function _fetchFromResource() {
  17. if ($this->_resource && $this->_resource->hasNext()) {
  18. $result = $this->_resource->getNext();
  19. $isFile = ($result instanceof MongoGridFSFile);
  20. $result = $isFile ? array('file' => $result) + $result->file : $result;
  21. $this->_key = $this->_iterator;
  22. $this->_current = $this->_cache[$this->_iterator++] = $result;
  23. return true;
  24. }
  25. return false;
  26. }
  27. }
  28. ?>