Best way to use a postgresql sproc (returning ref cursor) with PHP? -


I am using stored procs and calling them with PHP (I also use the same process in the Java app I'm using).

Now I do it like this (which works):

  if (! ($ Result = pg_query ($ connection, 'BEGIN; SELECT') $ Query) 'FETCH ALL IN' .self :: $ cursor. ';' '))) Blank return;  $ query  is something like ""  create a call ('foo', 'bar', 'etc')  "and  $ cursor  is simply "ref_cursor", because this is the cursor name (and yes, I know it looks like a hack ...). 

Know about the benefits (and prepared statements), and I wonder if there is any point in executing the above. A process is already compiled as I know, but there is no query above. Am I fooling myself into believing that I will get some benefit in it? I am compelled for my processes because I have an auto generator in Java which writes them for me, using PDOs in this case I have searched on the net for something on pgsql ref cursor + pdo, but I did not find much. I know that I just use the prepared statements of PDO But it does not cooperate with my processes.

-Yngve

'Better Way' will use pg_query_params, but you only send 1 query / statement at a time:

  pg_query_params ('SELECT process_name ($ 1, $ 2);' .ray ( 'Foo', 'bar'));  

Comments