Exemplo n.º 1
0
 /**
  * Allows for iteration over result sets.
  *
  * @param string $type One of 'next' or 'close'.
  * @param object $resource The resource to act upon.
  * @param object $context
  * @return mixed If `$type` is `next` and the resource has a `next` item, that item is
  *         returned. Null otherwise.
  */
 public function result($type, $resource, $context)
 {
     if (!is_object($resource)) {
         return null;
     }
     switch ($type) {
         case 'next':
             $result = $resource->hasNext() ? $resource->getNext() : null;
             if ($result instanceof MongoGridFSFile) {
                 $result = array('file' => $result) + $result->file;
             }
             break;
         case 'close':
             unset($resource);
             $result = null;
             break;
         default:
             $result = parent::result($type, $resource, $context);
             break;
     }
     return $result;
 }
Exemplo n.º 2
0
 public function result($type, $resource, $context)
 {
     if (!is_object($resource)) {
         return null;
     }
     switch ($type) {
         case 'next':
             $result = $resource->hasNext() ? $resource->getNext() : null;
             break;
         case 'close':
             unset($resource);
             $result = null;
             break;
         default:
             $result = parent::result($type, $resource, $context);
             break;
     }
     return $result;
 }