I have a server that only has php4 and postgresql. As far as I can tell PDO and pg_query_params don't exist in php4. What alternatives are there? Or is raw escaping the only option?
PEAR DB started out in PHP 4; you can probably still find a version somewhere that supports it. I used to use it before switching to PHP 5 and PDO; it's pretty decent if you're stuck with PHP 4.
Really, though, your priority should be to get as far away from PHP 4 as possible. It hasn't been supported for years, sucks at handling objects, and is wretchedly slow compared to PHP 5. Plus, PHP 5 has PDO.