Unix and Linux Discussions Tagged with shellscripting |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
4 |
4,119 |
Shell Programming and Scripting |
|
|
|
1 |
1,074 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
1,254 |
Shell Programming and Scripting |
|
|
|
3 |
1,468 |
Shell Programming and Scripting |
|
|
|
8 |
2,046 |
Shell Programming and Scripting |
|
|
|
15 |
2,880 |
Shell Programming and Scripting |
|
|
|
3 |
763 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
7,138 |
Shell Programming and Scripting |
|
|
|
1 |
2,832 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
2,911 |
Shell Programming and Scripting |
|
|
|
6 |
2,027 |
Shell Programming and Scripting |
|
|
|
2 |
1,261 |
Shell Programming and Scripting |
|
|
|
2 |
1,108 |
Shell Programming and Scripting |
|
|
|
3 |
71,900 |
Shell Programming and Scripting |
|
|
|
4 |
3,068 |
Shell Programming and Scripting |
|
|
|
4 |
5,782 |
Shell Programming and Scripting |
|
|
|
4 |
35,779 |
Shell Programming and Scripting |
|
|
|
2 |
5,196 |
Shell Programming and Scripting |
|
|
|
4 |
3,839 |
Shell Programming and Scripting |
|
|
|
3 |
2,575 |
Shell Programming and Scripting |
|
|
|
2 |
3,442 |
Shell Programming and Scripting |
|
|
|
3 |
20,875 |
Shell Programming and Scripting |
|
|
|
2 |
1,745 |
Shell Programming and Scripting |
|
|
|
1 |
2,536 |
Shell Programming and Scripting |
|
|
|
5 |
1,849 |
Shell Programming and Scripting |
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)