PDOStatement::fetchSingle

(no version information, might be only in CVS)

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

Descripción

string PDOStatement::fetchSingle ( void )

Aviso

Esta función es EXPERIMENTAL. Esto significa que el comportamiento de esta función, el nombre de esta función y en definitiva TODO lo documentado sobre esta función, puede cambiar en una futura version de PHP SIN AVISO. La advertencia queda hecha, y utilizar esta extensión queda bajo su propia responsabilidad.

Valores retornados

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

Aviso

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

Ejemplos

Ejemplo 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");
?>

El resultado del ejemplo seria:

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

Ver también

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