PG_AFFECTED_ROWS(3) PG_AFFECTED_ROWS(3)
pg_affected_rows - Returns number of affected records (tuples)
SYNOPSIS
int pg_affected_rows (resource $result)
DESCRIPTION
pg_affected_rows(3) returns the number of tuples (instances/records/rows) affected by INSERT, UPDATE, and DELETE queries.
Since PostgreSQL 9.0 and above, the server returns the number of SELECTed rows. Older PostgreSQL return 0 for SELECT.
Note
This function used to be called pg_cmdtuples(3).
PARAMETERS
o $result
- PostgreSQL query result resource, returned by pg_query(3), pg_query_params(3) or pg_execute(3) (among others).
RETURN VALUES
The number of rows affected by the query. If no tuple is affected, it will return 0.
EXAMPLES
Example #1
pg_affected_rows(3) example
<?php
$result = pg_query($conn, "INSERT INTO authors VALUES ('Orwell', 2002, 'Animal Farm')");
$cmdtuples = pg_affected_rows($result);
echo $cmdtuples . " tuples are affected.
";
?>
The above example will output:
1 tuples are affected.
SEE ALSO
pg_query(3), pg_query_params(3), pg_execute(3), pg_num_rows(3).
PHP Documentation Group PG_AFFECTED_ROWS(3)