array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.pg-affected-rows.php', 1 => 'pg_affected_rows', ), 'up' => array ( 0 => 'ref.pgsql.php', 1 => 'PostgreSQL 函数', ), 'prev' => array ( 0 => 'ref.pgsql.php', 1 => 'PostgreSQL 函数', ), 'next' => array ( 0 => 'function.pg-cancel-query.php', 1 => 'pg_cancel_query', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/pgsql/functions/pg-affected-rows.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
pg_affected_rows — 返回受影响的记录数(元组)
pg_affected_rows() 返回受 INSERT
、UPDATE
和 DELETE
查询影响的元组数(实例/记录/行)。
从 PostgreSQL 9.0 及更高版本开始,服务器返回 SELECT 的行数。较旧的 PostgreSQL 则返回 0。
注意:
此函数过去称为 pg_cmdtuples()。
受查询影响的行数。如果没有元组受到影响,它将返回 0
。
版本 | 说明 |
---|---|
8.1.0 |
现在 result 参数接受 PgSql\Result
实例,之前接受 resource。
|
示例 #1 pg_affected_rows() 示例
<?php
$result = pg_query($conn, "INSERT INTO authors VALUES ('Orwell', 2002, 'Animal Farm')");
$cmdtuples = pg_affected_rows($result);
echo $cmdtuples . " tuples are affected.\n";
?>
以上示例会输出:
1 tuples are affected.