pdostatement.fetchcolumn(3) php man page | unix.com

Man Page: pdostatement.fetchcolumn

Operating Environment: php

Section: 3

PDOSTATEMENT.FETCHCOLUMN(3)						 1					       PDOSTATEMENT.FETCHCOLUMN(3)

PDOStatement::fetchColumn - Returns a single column from the next row of a result set

SYNOPSIS
public mixed PDOStatement::fetchColumn ([int $column_number])
DESCRIPTION
Returns a single column from the next row of a result set or FALSE if there are no more rows. Note PDOStatement.fetchColumn(3) should not be used to retrieve boolean columns, as it is impossible to distinguish a value of FALSE from there being no more rows to retrieve. Use PDOStatement.fetch(3) instead.
PARAMETERS
o $column_number - 0-indexed number of the column you wish to retrieve from the row. If no value is supplied, PDOStatement.fetchColumn(3) fetches the first column.
RETURN VALUES
PDOStatement.fetchColumn(3) returns a single column in the next row of a result set. Warning There is no way to return another column from the same row if you use PDOStatement.fetchColumn(3) to retrieve data.
EXAMPLES
Example #1 Return first column of the next row <?php $sth = $dbh->prepare("SELECT name, colour FROM fruit"); $sth->execute(); print("Fetch the first column from the first row in the result set: "); $result = $sth->fetchColumn(); print("name = $result "); print("Fetch the second column from the second row in the result set: "); $result = $sth->fetchColumn(1); print("colour = $result "); ?> The above example will output: Fetch the first column from the first row in the result set: name = lemon Fetch the second column from the second row in the result set: colour = red
SEE ALSO
PDO.query(3), PDOStatement.fetch(3), PDOStatement.fetchAll(3), PDO.prepare(3), PDOStatement.setFetchMode(3). PHP Documentation Group PDOSTATEMENT.FETCHCOLUMN(3)
Related Man Pages
pdostatement.debugdumpparams(3) - php
pdostatement.fetchall(3) - php
pdo.prepare(3) - php
pdostatement.bindcolumn(3) - php
pdo.exec(3) - php
Similar Topics in the Unix Linux Community
Columns to rows
Split file - Include first and last row in each file.
have to retrieve the distinct values (not duplicate) from 2nd column and display
awk to print all row to one line
Deleting row if all column values are a particular string