yii\mongodb\Query::fetchRowsInternal PHP Method

fetchRowsInternal() protected method

See also: Query::fetchRows()
protected fetchRowsInternal ( MongoDB\Driver\Cursor $cursor, boolean $all ) : array | boolean
$cursor MongoDB\Driver\Cursor Mongo cursor instance to fetch data from.
$all boolean whether to fetch all rows or only first one.
return array | boolean result.
    protected function fetchRowsInternal($cursor, $all)
    {
        $result = [];
        if ($all) {
            foreach ($cursor as $row) {
                $result[] = $row;
            }
        } else {
            if ($row = current($cursor->toArray())) {
                $result = $row;
            } else {
                $result = false;
            }
        }
        return $result;
    }