Just a forward-only cursor is required, not necessarily a rolling cursor. Not all data sources can support rolling cursors, that's why forward-only cursors have been chosen here as the least common denominator for the abstraction. Rolling cursors cannot be emulated from an underlying forward-only cursor in a (memory) efficient way. Result does not try to and will deliberately not keep already yielded results in an internal cache. To allow full (back and forth) iteration over the yielded results, a wrapping class (i.e. Collection) may keep such a cache while draining the Result from outside. Because of these characteristics an instance of Result may be used only once. After draining the result it cannot be rewinded or reset. This is similar to the behavior of the NoRewindIterator, where rewind calls have no effect. The first result will be eager loaded from the cursor, as it is expected the result will be used at least once. The class also provides a mechanism which buffers results when peeking for next ones. The buffered results will then be used when continuing to iterate over the result object.
Inheritance: extends lithium\core\Object, implements Iterator
Beispiel #1
0
 /**
  * Builds an array of keyed on the fully-namespaced `Model` with array of fields as values
  * for the given `Query`
  *
  * @param \lithium\data\model\Query $query A Query instance.
  * @param \lithium\data\source\Result|null $resource An optional a result resource.
  * @param object|null $context
  * @return array
  */
 public function schema($query, $resource = null, $context = null)
 {
     if (is_object($query)) {
         $query->applyStrategy($this);
         return $this->_schema($query, $this->_fields($query->fields(), $query));
     }
     $result = array();
     if (!$resource || !$resource->resource()) {
         return $result;
     }
     $count = $resource->resource()->columnCount();
     for ($i = 0; $i < $count; $i++) {
         $meta = $resource->resource()->getColumnMeta($i);
         $result[] = $meta['name'];
     }
     return $result;
 }