當前位置: 首頁>>代碼示例>>PHP>>正文


PHP resource::valid方法代碼示例

本文整理匯總了PHP中resource::valid方法的典型用法代碼示例。如果您正苦於以下問題:PHP resource::valid方法的具體用法?PHP resource::valid怎麽用?PHP resource::valid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在resource的用法示例。


在下文中一共展示了resource::valid方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _get_result

 /**
  * Method used to get a row from the executed query
  * 
  * @return  array              An array containing the row data of the result
  * @access  private
  */
 private function _get_result()
 {
     if ($this->_result->valid()) {
         $row = $this->_result->current();
         if ($this->config_item('mongo_expand_dbrefs')) {
             $this->_deref($row);
         }
         return $row;
     } else {
         return array();
     }
 }
開發者ID:asalem,項目名稱:CodeIgniter-MongoDB,代碼行數:18,代碼來源:Mongo_db_result.php

示例2: next

 /**
  * Advanced to the next context.
  *
  * This method parses a little bit more of the XML file to be able to
  * return the next context.  If no more contexts are available it sets the
  * $currentContext member variable to null, so that the valid() method can
  * pick this up.  If there are more contexts available it reads the context
  * from the file and stores it into the $currentContext member variable.
  * This method is used for iteration as part of the Iterator interface.
  *
  * @throws ezcTranslationReaderNotInitializedException when the reader is
  *         not initialized with initReader().
  * @return void
  */
 public function next()
 {
     if (is_null($this->xmlParser)) {
         throw new ezcTranslationReaderNotInitializedException();
     }
     $valid = $this->xmlParser->valid();
     if ($valid) {
         $newContext = array(trim($this->xmlParser->getChildren()->name), array());
         foreach ($this->xmlParser->getChildren()->message as $data) {
             $translationItem = $this->parseSimpleXMLMessage($data);
             if (!is_null($translationItem)) {
                 $newContext[1][] = $translationItem;
             }
         }
         $this->currentContext = $newContext;
         $this->xmlParser->next();
     } else {
         $this->currentContext = null;
     }
 }
開發者ID:zetacomponents,項目名稱:translation,代碼行數:34,代碼來源:ts_backend.php

示例3: write

 /**
  * Writes input to stdin.
  *
  * @throws InvalidArgumentException When an input iterator yields a non supported value
  */
 protected function write()
 {
     if (!isset($this->pipes[0])) {
         return;
     }
     $input = $this->input;
     if ($input instanceof \Iterator) {
         if (!$input->valid()) {
             $input = null;
         } elseif (is_resource($input = $input->current())) {
             stream_set_blocking($input, 0);
         } elseif (!isset($this->inputBuffer[0])) {
             if (!is_string($input)) {
                 if (!is_scalar($input)) {
                     throw new InvalidArgumentException(sprintf('%s yielded a value of type "%s", but only scalars and stream resources are supported', get_class($this->input), gettype($input)));
                 }
                 $input = (string) $input;
             }
             $this->inputBuffer = $input;
             $this->input->next();
             $input = null;
         } else {
             $input = null;
         }
     }
     $r = $e = array();
     $w = array($this->pipes[0]);
     // let's have a look if something changed in streams
     if (false === ($n = @stream_select($r, $w, $e, 0, 0))) {
         return;
     }
     foreach ($w as $stdin) {
         if (isset($this->inputBuffer[0])) {
             $written = fwrite($stdin, $this->inputBuffer);
             $this->inputBuffer = substr($this->inputBuffer, $written);
             if (isset($this->inputBuffer[0])) {
                 return array($this->pipes[0]);
             }
         }
         if ($input) {
             for (;;) {
                 $data = fread($input, self::CHUNK_SIZE);
                 if (!isset($data[0])) {
                     break;
                 }
                 $written = fwrite($stdin, $data);
                 $data = substr($data, $written);
                 if (isset($data[0])) {
                     $this->inputBuffer = $data;
                     return array($this->pipes[0]);
                 }
             }
             if (feof($input)) {
                 if ($this->input instanceof \Iterator) {
                     $this->input->next();
                 } else {
                     $this->input = null;
                 }
             }
         }
     }
     // no input to read on resource, buffer is empty
     if (!isset($this->inputBuffer[0]) && !($this->input instanceof \Iterator ? $this->input->valid() : $this->input)) {
         $this->input = null;
         fclose($this->pipes[0]);
         unset($this->pipes[0]);
     } elseif (!$w) {
         return array($this->pipes[0]);
     }
 }
開發者ID:ayoah,項目名稱:symfony,代碼行數:75,代碼來源:AbstractPipes.php

示例4: getSourceFields

 /**
  * {@inheritdoc}
  */
 public function getSourceFields($url)
 {
     if (!$this->getSourceData($url)) {
         return array();
     }
     // Recurse through the result array. When there is an array of items at the
     // expected depth that has the expected identifier as one of the keys, pull that
     // array out as a distinct item.
     $identifier = $this->getIdentifier();
     $identifierDepth = $this->getIdentifierDepth();
     $items = array();
     while ($this->iterator->valid()) {
         $this->iterator->next();
         $item = $this->iterator->current();
         if (is_array($item) && array_key_exists($identifier, $item) && $this->iterator->getDepth() == $identifierDepth) {
             $items[] = $item;
         }
     }
     return $items;
 }
開發者ID:karens,項目名稱:migrate_source_json,代碼行數:23,代碼來源:JSONReader.php

示例5: write

 /**
  * Writes input to stdin.
  */
 protected function write()
 {
     if (!isset($this->pipes[0])) {
         return;
     }
     $input = $this->input;
     if ($input instanceof \Iterator) {
         if (!$input->valid()) {
             $input = null;
         } elseif (is_resource($input = $input->current())) {
             stream_set_blocking($input, 0);
         } else {
             $this->inputBuffer .= $input;
             $this->input->next();
             $input = null;
         }
     }
     $r = $e = array();
     $w = array($this->pipes[0]);
     // let's have a look if something changed in streams
     if (false === ($n = @stream_select($r, $w, $e, 0, 0))) {
         return;
     }
     foreach ($w as $stdin) {
         if (isset($this->inputBuffer[0])) {
             $written = fwrite($stdin, $this->inputBuffer);
             $this->inputBuffer = substr($this->inputBuffer, $written);
             if (isset($this->inputBuffer[0])) {
                 return array($this->pipes[0]);
             }
         }
         if ($input) {
             for (;;) {
                 $data = fread($input, self::CHUNK_SIZE);
                 if (!isset($data[0])) {
                     break;
                 }
                 $written = fwrite($stdin, $data);
                 $data = substr($data, $written);
                 if (isset($data[0])) {
                     $this->inputBuffer = $data;
                     return array($this->pipes[0]);
                 }
             }
             if (feof($input)) {
                 if ($this->input instanceof \Iterator) {
                     $this->input->next();
                 } else {
                     $this->input = null;
                 }
             }
         }
     }
     // no input to read on resource, buffer is empty
     if (!isset($this->inputBuffer[0]) && !($this->input instanceof \Iterator ? $this->input->valid() : $this->input)) {
         $this->input = null;
         fclose($this->pipes[0]);
         unset($this->pipes[0]);
     }
     if (!$w) {
         return array($this->pipes[0]);
     }
 }
開發者ID:hason,項目名稱:symfony,代碼行數:66,代碼來源:AbstractPipes.php


注:本文中的resource::valid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。