PHP 手冊
前一頁 |  | 下一頁

# PDOStatement::fetchSingle

(no version information, might be only in CVS)

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

## Description

string PDOStatement::fetchSingle ( void )

警告
這個函數是實驗性質的。這個函數的行為、名稱、和關於此函數的任何其他文件在未來PHP的發行中可能會在不通知的情況下改變。 使用此延伸需自行承擔風險。

## Return Values

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

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

## 範例

範例 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"); ?>`

The above example will output:

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

## 參考

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

前一頁 | 內容 | 下一頁
PDOStatement::fetchAll | 上一層 | PDOStatement::getAttribute