PHP Function Pg_Affected_Rows
php function pg_affected_rows is one of the most important routines for using PostgreSQL from your php application. The function can help you know the number of rows that has been affected by INSERT, UPDATE or DELETE queries in your database.
Its a simple and powerful function for getting the number of rows affected by a SQL query. It is very helpful for developers and webmasters who use PostgreSQL in their applications. The php function can be used with either the mysql or postgres database.
The function accepts a parameter called query_str. The query_str is a string that contains the SQL statement to execute. It can also contain the BEGIN and COMMIT statements, but it is not recommended to use multiple transactions within a single call to a query function. The function also accepts an argument called assoc_array. The assoc_array is an array of values that will be inserted into the table specified by the table_name. The assoc_array must have as many elements as the number of columns in the table.
The pg_affected_rows() function returns the number of tuples (instances/records/rows) affected by INSERT, UPDATE, and DELETE queries. It can return 0 if the query was a SELECT query. Unlike @@ROWCOUNT, which only works on DDL statements like INSERT, UPDATE and DELETE, pg_affected_rows() returns the row count for all tuples in the result of a query, including those that were returned as NULL. This differs from MySQL and MariaDB, which only return the ROWCOUNT value for SELECT queries.