yii\mongodb\Query::fetchRows PHP Method

fetchRows() protected method

Fetches rows from the given Mongo cursor.
protected fetchRows ( MongoDB\Driver\Cursor $cursor, boolean $all = true, string | callable $indexBy = null ) : array | boolean
$cursor MongoDB\Driver\Cursor Mongo cursor instance to fetch data from.
$all boolean whether to fetch all rows or only first one.
$indexBy string | callable the column name or PHP callback, by which the query results should be indexed by.
return array | boolean result.
    protected function fetchRows($cursor, $all = true, $indexBy = null)
    {
        $token = 'fetch cursor id = ' . $cursor->getId();
        Yii::info($token, __METHOD__);
        try {
            Yii::beginProfile($token, __METHOD__);
            $result = $this->fetchRowsInternal($cursor, $all);
            Yii::endProfile($token, __METHOD__);
            return $result;
        } catch (\Exception $e) {
            Yii::endProfile($token, __METHOD__);
            throw new Exception($e->getMessage(), (int) $e->getCode(), $e);
        }
    }