PDOStatement::fetchSingle

(no version information, might be only in CVS)

PDOStatement::fetchSingle --  Returns the first column in the next row of a result set

Popis

string PDOStatement::fetchSingle ( void )

Varování

Tato funkce je EXPERIMENTÁLNÍ. Chování této funkce, její název a všechno ostatní, co je zde zdokumentováno, se v budoucích verzích PHP může BEZ OHLÁŠENÍ změnit. Berte to v úvahu a používejte tuto funkci na vlastní nebezpečí.

Návratové hodnoty

PDOStatement::fetchSingle() returns the first column in the next row of a result set as a string value.

Varování

There is no way to return the second or subsequent columns from a row if you use this method to retrieve data.

Příklady

Příklad 1. Return first column of the next row

<?php
$sth
= $dbh->prepare("SELECT name, colour FROM fruit");
$sth->execute();

/* Fetch the first column from the next row in the result set */
print("Fetch the first column from the next row in the result set:\n");
$result = $sth->fetchSingle();
print(
"$result\n");

$result = $sth->fetchSingle();
print(
"$result\n");
?>

Výše uvedený příklad vypíše:

Fetch the first column from the next row in the result set:
lemon
orange

Viz také

PDO::query()
PDOStatement::fetch()
PDOStatement::fetchAll()
PDOStatement::prepare()
PDOStatement::setFetchMode()