Exemple #1
0
 /**
  * Opens up stream
  * @return resource
  */
 function open()
 {
     if (isset($this->context)) {
         $this->pointer = fopen($this->resource->getPath(), $this->mode->value(), false, $this->context);
     } else {
         $this->pointer = fopen($this->resource->getPath(), $this->mode->value());
     }
     if ($this->pointer) {
         parent::open();
     }
     return $this->pointer;
 }
Exemple #2
0
 /**
  * Executes query
  * Assembles query if necessary
  * Opens stream if not already open
  * Closes stream after result iteration/translation
  * @return \qinq\Collection
  */
 public function execute()
 {
     $this->assemble();
     $result = [];
     $it = $this->getIterator();
     if ($it instanceof \Iterator) {
         if (!$this->stream->isOpen()) {
             $this->stream->open();
         }
         foreach ($it as $key => $value) {
             $result[$key] = $this->translate($value);
         }
         $this->stream->close();
         $this->assembled = false;
         $this->setFilters([]);
     }
     return new qinq\Collection($result);
 }