Thanks - I think that's the best solution.

Chris

Ilia Alshanetsky wrote:
iliaa           Thu Jul  7 09:35:41 2005 EDT

Modified files: /php-src/ext/pdo_pgsql config.m4 pgsql_driver.c Log:
  Use PQexecParams() when available, use original case in all other instances.
http://cvs.php.net/diff.php/php-src/ext/pdo_pgsql/config.m4?r1=1.10&r2=1.11&ty=u
Index: php-src/ext/pdo_pgsql/config.m4
diff -u php-src/ext/pdo_pgsql/config.m4:1.10 
php-src/ext/pdo_pgsql/config.m4:1.11
--- php-src/ext/pdo_pgsql/config.m4:1.10        Mon Jun 13 20:00:53 2005
+++ php-src/ext/pdo_pgsql/config.m4     Thu Jul  7 09:35:39 2005
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4,v 1.10 2005/06/14 00:00:53 sniper Exp $
+dnl $Id: config.m4,v 1.11 2005/07/07 13:35:39 iliaa Exp $
 dnl
if test "$PHP_PDO" != "no"; then
@@ -90,6 +90,7 @@
   AC_CHECK_LIB(pq, 
PQprotocolVersion,AC_DEFINE(HAVE_PQPROTOCOLVERSION,1,[PostgreSQL 7.4 or later]))
   AC_CHECK_LIB(pq, 
PQtransactionStatus,AC_DEFINE(HAVE_PGTRANSACTIONSTATUS,1,[PostgreSQL 7.4 or 
later]))
   AC_CHECK_LIB(pq, 
PQunescapeBytea,AC_DEFINE(HAVE_PQUNESCAPEBYTEA,1,[PostgreSQL 7.4 or later]))
+  AC_CHECK_LIB(pq, PQExecParams,AC_DEFINE(HAVE_PQEXECPARAMS,1,[PostgreSQL 7.4 
or later]))
   AC_CHECK_LIB(pq, 
PQresultErrorField,AC_DEFINE(HAVE_PQRESULTERRORFIELD,1,[PostgreSQL 7.4 or 
later]))
   AC_CHECK_LIB(pq, 
pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether 
libpq is compiled with --enable-multibyte]))
   LIBS=$old_LIBS
http://cvs.php.net/diff.php/php-src/ext/pdo_pgsql/pgsql_driver.c?r1=1.48&r2=1.49&ty=u
Index: php-src/ext/pdo_pgsql/pgsql_driver.c
diff -u php-src/ext/pdo_pgsql/pgsql_driver.c:1.48 
php-src/ext/pdo_pgsql/pgsql_driver.c:1.49
--- php-src/ext/pdo_pgsql/pgsql_driver.c:1.48   Wed Jul  6 22:17:20 2005
+++ php-src/ext/pdo_pgsql/pgsql_driver.c        Thu Jul  7 09:35:39 2005
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
-/* $Id: pgsql_driver.c,v 1.48 2005/07/07 02:17:20 iliaa Exp $ */
+/* $Id: pgsql_driver.c,v 1.49 2005/07/07 13:35:39 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -210,12 +210,22 @@
                *len = spprintf(&id, 0, "%ld", (long) H->pgoid);
        } else {
                PGresult *res;
-               char *q;
                ExecStatusType status;
-
-               spprintf(&q, sizeof("SELECT CURRVAL('')") + strlen(name), "SELECT 
CURRVAL('%s')", name);
+#ifdef HAVE_PQEXECPARAMS
+               const char *q[1];
+               q[0] = name;
+               res = PQexecParams(H->server, "SELECT CURRVAL($1)", 1, NULL, q, 
NULL, NULL, 0);
+#else
+               char *name_escaped, *q;
+               size_t l = strlen(name);
+ + name_escaped = safe_emalloc(l, 2, 1);
+               PQescapeString(name_escaped, name, l);
+               spprintf(&q, 0, "SELECT CURRVAL('%s')", name_escaped);
                res = PQexec(H->server, q);
+ efree(name_escaped); efree(q);
+#endif
                status = PQresultStatus(res);
if (res && (status == PGRES_TUPLES_OK)) {


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to