Returns the nth column from the current row.
@return scalar or NULL on EOF
484429
public function scalar($idx=0)
    {
        $row = $this->row();

        if(is_null($row))

            return NULL;

        $values = is_numeric($idx) ? array_values($row) : $row;

        return $values[$idx];
    }
977666
public function numCellsTotal()
    {
        $numCells = 0;
        foreach ($this->structure as $row) {
            $rowCols = isset($row['columns']) ? count($row['columns']) : 0;
            $numCells += $rowCols;
        }
        return $numCells;
    }
674126
public function getRowAt($row_num)
    {
        if ($this->seek($row_num)) {
            $this->next();

            return $this->getCurrentRow();
        } else {
            return null;
        }
    }
180424
public function lastRow()
    {
        $query = clone $this;
        $offset = $this->limit ? $this->limit['start'] : 0;

        // Limit index to start in case of empty results
        $index = max($this->count() + $offset - 1, 0);
        $query->setLimit(1, $index);
        return $query;
    }
841023
protected function getNextDataSet()
    {
        $set = $this->file->fgetcsv($this->delimiter, $this->enclosure, $this->escape);

        if (is_array($set) && 1 === count($set) && null === $set[0]) {
            if ($this->skipEmptyLines && !$this->file->eof()) {
                return $this->getNextDataSet();
            }

            return null;
        }

        if ($this->removeBom) {
            if (substr($set[0], 0, 3) == pack("CCC", 0xef, 0xbb, 0xbf)) {
                $set[0] = substr($set[0], 3);
            }
            $this->removeBom = false;
        }

        $set = $this->convertEncoding($set);

        $this->line++;

        return $set;
    }
1046854
public function current()
	{
		$row = fgetcsv($this->file, self::ROW_LENGTH, $this->delimiter);
		$this->position++;

		// store headers for later
		if ($this->position == 1)
		{
			$this->headers = $row;
		}

		// return null for the first row and last row if empty
		// we dont want to count the headings row
		if ($this->position == 1 || $row === false)
		{
			return null;
		}

		// map headings
		$object = new stdClass;
		foreach ($this->headers as $k => $header)
		{
			$header = trim($header);
			$header = trim($header, ':');
			$header = ($header ?: 'COLUMN');

			// If a column header contains a colon, we break it
			// into a sub-object with properties.
			//
			// Address:street, Address:city
			//  ->  Address => { street = data, city = data }
			//
			if (strpos($header, ':'))
			{
				$parts = explode(':', $header);

				// Make sure we have more than one part
				if (count($parts) > 1)
				{
					if (!isset($object->{$parts[0]}) || !is_object($object->{$parts[0]}))
					{
						$object->{$parts[0]} = new stdClass;
					}
					$object->{$parts[0]}->{$parts[1]} = $row[$k];
				}
				else
				{
					$object->$header = $row[$k];
				}
			}
			else
			{
				$object->$header = $row[$k];
			}
		}

		// return as object
		return $object;
	}
238854
public function getColumnCount()
    {
        $columnCount = 0;
        foreach ($this->_cells as $item) {
            if ($item->columns === 'auto') {
                continue;
            }
            $columnCount += $item->columns;
        }

        return $columnCount;
    }
579021
public function findFirst()
    {
        $rowset = $this->getTableGateway()
            ->select(
                function(Select $select) {
                    $select->columns($this->columns);
                    $select->limit(1);
                    $select->order('id asc');
                }
            );
        $row = $rowset->current();
        if (!$row) {
            return NULL;
        }
        return $row;
    }
403995
public function getFirstRow()
    {
        $rows = $this->data['rows'];
        if (empty($rows)) {
            return false;
        }

        $row = array_slice($rows, 0, 1);

        return current($row);
    }
880116
public function getColumnOffset() {
        // strrpos is weird, and the offset needs to be negative for what we
        // want (i.e., the last \n before $this->char). This needs to not have
        // one (to make it point to the next character, the one we want the
        // position of) added to it because strrpos's behaviour includes the
        // final offset byte.
        $lastLine = strrpos($this->data, "\n", $this->char - 1 - strlen($this->data));

        // However, for here we want the length up until the next byte to be
        // processed, so add one to the current byte ($this->char).
        if ($lastLine !== false) {
            $findLengthOf = substr($this->data, $lastLine + 1, $this->char - 1 - $lastLine);
        } else {
            $findLengthOf = substr($this->data, 0, $this->char);
        }

        // Get the length for the string we need.
        if (extension_loaded('iconv')) {
            return iconv_strlen($findLengthOf, 'utf-8');
        } elseif (extension_loaded('mbstring')) {
            return mb_strlen($findLengthOf, 'utf-8');
        } elseif (extension_loaded('xml')) {
            return strlen(utf8_decode($findLengthOf));
        } else {
            $count = count_chars($findLengthOf);
            // 0x80 = 0x7F - 0 + 1 (one added to get inclusive range)
            // 0x33 = 0xF4 - 0x2C + 1 (one added to get inclusive range)
            return array_sum(array_slice($count, 0, 0x80)) +
                   array_sum(array_slice($count, 0xC2, 0x33));
        }
    }
1259111
public function getColumnAttr()
    {
        $attr = [];

        foreach ($this->column as $item) {
            if (is_array($item))
                $attr = array_merge($attr, $item);
            else
                $attr[] = $item;
        }

        return array_unique(array_values($attr));
    }
1254131
protected function scanTableRow()
    {
        if (!$this->allowMultilineArguments) {
            return null;
        }

        $line = $this->getTrimmedLine();
        if (!isset($line[0]) || '|' !== $line[0] || '|' !== substr($line, -1)) {
            return null;
        }

        $token = $this->takeToken('TableRow');
        $line = mb_substr($line, 1, mb_strlen($line, 'utf8') - 2, 'utf8');
        $columns = array_map(function ($column) {
            return trim(str_replace('\\|', '|', $column));
        }, preg_split('/(?<!\\\)\|/u', $line));
        $token['columns'] = $columns;

        $this->consumeLine();

        return $token;
    }
335503
public function getAt(): int
    {
        if ($this->at < 0) {
            return Location::BeforeFirstRow;
        }

        if ($this->at > $this->rowCount()) {
            return Location::AfterLastRow;
        }

        return $this->at;
    }
261239
public function getFirstRow()
    {
        if (count($this->rows) == 0) {
            if (!is_null($this->summaryRow)) {
                return $this->summaryRow;
            }
            return false;
        }
        return reset($this->rows);
    }
649793
public function fetchColumn()
    {
        $spec = $this->getResult();

        $data = $spec->fetch_row();
        if( is_array($data) ) {
            $data = current($data);
        }

        $this->free();
        return $data;
    }
230745
public function getColumnsHash()
    {
        $rows = $this->getRows();
        $keys = array_shift($rows);

        $hash = array();
        foreach ($rows as $row) {
            $hash[] = array_combine($keys, $row);
        }

        return $hash;
    }
235424
public function getQueryLimit()
    {
        if ($this->limit !== null && $this->offset !== null) {
            return 'LIMIT ' . $this->offset . ', ' . $this->limit;
        } else {
            if (null !== $this->limit) {
                return 'LIMIT ' . $this->limit;
            } else {
                return '';
            }
        }
    }