/** * Is the query iterating yet? * * @link http://www.php.net/manual/en/mongocursor.info.php \MongoCursor::info * * @since 0.3.0 * @since 1.0.0 is_iterating → isIterating * * @return boolean */ public function isIterating() { if (!$this->cursor) { return false; } $info = $this->cursor->info(); return $info['started_iterating']; }
/** * Wrapper method for MongoCursor::key(). * * @see http://php.net/manual/en/iterator.key.php * @see http://php.net/manual/en/mongocursor.key.php * @return mixed */ public function key() { // TODO: Track position internally to avoid repeated info() calls if (!$this->useIdentifierKeys) { $info = $this->mongoCursor->info(); return isset($info['at']) ? $info['at'] : null; } return $this->mongoCursor->key(); }
/** * Is the query iterating yet? * * @throws Exception * @return bool */ public function is_iterating() { if (!$this->_cursor) { return FALSE; } $info = $this->_cursor->info(); if (!isset($info['started_iterating'])) { throw new Exception('Driver version >= 1.0.10 required.'); } return $info['started_iterating']; }
/** * Fetches rows from the given Mongo cursor. * @param \MongoCursor $cursor Mongo cursor instance to fetch data from. * @param boolean $all whether to fetch all rows or only first one. * @param string|callable $indexBy the column name or PHP callback, * by which the query results should be indexed by. * @throws Exception on failure. * @return array|boolean result. */ protected function fetchRows($cursor, $all = true, $indexBy = null) { $token = 'find(' . Json::encode($cursor->info()) . ')'; Yii::info($token, __METHOD__); try { Yii::beginProfile($token, __METHOD__); $result = $this->fetchRowsInternal($cursor, $all, $indexBy); Yii::endProfile($token, __METHOD__); return $result; } catch (\Exception $e) { Yii::endProfile($token, __METHOD__); throw new Exception($e->getMessage(), (int) $e->getCode(), $e); } }
/** * Fetches rows from the given Mongo cursor. * * @param \MongoCursor $cursor Mongo cursor instance to fetch data from. * @param boolean $all whether to fetch all rows or only first one. * @param string|callable $indexBy the column name or PHP callback, * by which the query results should be indexed by. * @throws MongoException on failure. * @return array|null result. */ protected function fetchRows($cursor, $all = true, $indexBy = null) { $rawQuery = 'find(' . Json::encode($cursor->info()) . ')'; //Log::info($token, __METHOD__); $token = ['query' => $rawQuery, 'valid' => true, 'cache' => false]; Trace::beginProfile('mongodb.query', $token); $cache = $cacheKey = null; $lock = true; if (($result = $this->getCache($rawQuery, $token, $all, $indexBy, $cache, $cacheKey, $lock)) !== false) { return $result; } if ($lock === false) { return null; } try { $result = $this->fetchRowsInternal($cursor, $all); $this->setCache($result, $cache, $cacheKey); Trace::endProfile('mongodb.query', $token); Trace::trace('mongodb.query', $token); return $result; } catch (\Exception $e) { $message = $e->getMessage() . "\nThe query being executed was: {$rawQuery}"; Trace::endProfile('mongodb.query', $token); $token['valid'] = false; $token['exception'] = defined('ROCK_DEBUG') && ROCK_DEBUG === true ? $e : $message; Trace::trace('mongodb.query', $token); if (isset($cache, $cacheKey) && $cache instanceof CacheInterface) { $cache->unlock($cacheKey); } throw new MongoException($message, [], 0, $e); } }
/** * Wrapper method for MongoCursor::info(). * * @see http://php.net/manual/en/mongocursor.info.php * @return array */ public function info() { return $this->mongoCursor->info(); }
/** * Gets the query, fields, limit, and skip for this cursor * @link http://www.php.net/manual/en/mongocursor.info.php * @return array The query, fields, limit, and skip for this cursor as an associative array. */ public function info() { return $this->cursor->info(); }
/** * * @return array */ public function info() { $info = $this->cursor->info(); return $info; }