PHP 手冊
前一頁 |  | 下一頁

# PDOStatement::rowCount

(no version information, might be only in CVS)

PDOStatement::rowCount -- Returns the number of rows affected by the last SQL statement

## Description

int PDOStatement::rowCount ( void )

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

PDOStatement::rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding PDOStatement object.

If the last SQL statement executed by the associated PDOStatement was a SELECT statement, some databases may return the number of rows returned by that statement. However, this behaviour is not guaranteed for all databases and should not be relied on for portable applications.

範例 1. Return the number of deleted rows
`<?php /* Delete all rows from the FRUIT table */ $del = $dbh->prepare('DELETE FROM fruit'); $del->execute(); /* Return number of rows that were deleted */ print("Return number of rows that were deleted:\n"); $count = $del->rowCount(); print("Deleted $count rows.\n"); ?>`

前一頁 | 內容 | 下一頁
PDOStatement::getColumnMeta | 上一層 | PDOStatement::setAttribute