Gonzalo Ayuso has posted a quick tutorial to his site showing you how to work with Foreign Data Wrappers on your PostgreSQL database in PHP. If you're not familiar with the data wrappers functionality, you can find out more on the PostgreSQL wiki.
PostgreSQL is more than a relational database. It has many cool features. Today we’re going to play with Foreign Data Wrappers (FDW). The idea is crate a virtual table from an external datasource and use it like we use a traditional table.
He gives an example of a simple RESTful service with a Silex application serving up a set of user data (names). He then switches over to the PostgreSQL side and shows how to create the data wrapper and set up the mapping of it to the REST server's location. With that set up you can then select from the data returned as if it were a normal table with a slight caveat - filtering (like with
where) must be done server side, not via the SQL statement.