Prev: Assigning the current value of a sequence to a variable- Postgres 8.3.6
Next: Trying to decide between MDB2 and PHP PDO
From: "Hartman, Matthew" on 17 Jun 2009 11:20 Good morning. Is there a way to use a returned refcursor from PostgreSQL using PDO? I have scoured the web and have yet to find a good result. Here's a few things I've tried. This example simply does not work. ----- $database = Database::load(); // Returns a singleton object with PDO connected to the database. $sql = "select my_function();"; $p = $database->query($sql); $p->execute(); $result = $p->fetchAll(); $p->closeCursor(); ----- This example is closer but PDO complains that the cursor is already open. ----- $database = Database::load(); // Returns a singleton object with PDO connected to the database. $sql = "BEGIN; select my_function('my_refcursor'); FETCH ALL from 'my_refcursor';"; $p = $database->query($sql); $p->execute(); $result = $p->fetchAll(); $p->closeCursor(); ----- Matthew Hartman Programmer/Analyst Information Management, ICP Kingston General Hospital (613) 549-6666 x4294 ..now. |