Retrieving an hierarchical tree recursively with PL/PgSQL

From PostgreSQL 8.4 you can write WITH queries using the optional RECURSIVE modifier to make a query refer to its own output.

Ok, but if I’m using a previous version of PostgreSQL? What can I do? I had this same question and, after some research, I found a solution based on functions.

Below I’ll explain how the functions works. Continue reading “Retrieving an hierarchical tree recursively with PL/PgSQL”

Connecting PHP to PostgreSQL via Unix sockets

I’ve searched the web looking for a way to connect a PHP application to PostgreSQL by Unix sockets using the pg_connect() function, but I didn’t find an answer to my situation.

Today using the trial and error method, I found a solution. There’s two ways to do the connection, since you have Unix socket connection enabled in your server:

Continue reading “Connecting PHP to PostgreSQL via Unix sockets”