Wow, so PHP must have started supporting explicit connect strings when I wasn't paying attention (and I tested it and yes, they really did... 🙂
The problem was likely that pg_query can use an implicit connect inside a function, but without globalling the connection string, it can't use an explicit one. I.e. These two work:
$conn = pg_connect(...
function a (b){
global $conn;
$res = pg_query($conn,"select * from test");
}
OR
$conn = pg_connect(...
function a (b){
$res = pg_query("select * from test");
}
But this won't:
$conn = pg_connect(...
function a (b){
$res = pg_query($conn,"select * from test");
}