Using pg_update() and pg_insert() without key validation is not secure!
You need to check which data pairs you get, and if you want to allow to updated this column.
Example:
You have a table with tree colums: username, password, userlevel.
Your users may change only their username, and their password but not their userlevel.
If you don't filter the keys in the request array, every user can now change his userlevel just by sending a POST Request with "userlevel=>100".
So if you don't check if the key are allowed in your request array you'll get serious sql injection vulnarabilities in your code.