title: Escape SQL queries in PHP PostgreSQL
body: <p>I have a website with lots of PHP files (really a lot...), which use the <code>pg_query</code> and <code>pg_exec</code> functions which do not 
  escape the apostrophe in Postgre SQL queries.  </p>
  
  <p>However, for security reasons and the ability to store names with
  apostrophe in my database I want to add an escaping mechanism for my database input. A possible solution is to go
  through every PHP file and change the <code>pg_query</code> and <code>pg_exec</code> to use <code>pg_query_params</code> but it is both time consuming
  and error prone. A good idea would be to somehow override the <code>pg_query</code> and <code>pg_exec</code> to wrapper functions that would 
  do the escaping without having to change any PHP file but in this case I guess I will have to change PHP function
  definitions and recompile it which is not very ideal. </p>
  
  <p>So, the question is open and any ideas that would
  allow to do what I want with minimum time consumption are very welcome. </p>