iliaa Wed Oct 4 23:27:03 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/pgsql pgsql.c config.m4 /php-src NEWS Log: Added support for character sets in pg_escape_string() for PostgreSQL 8.1.4 and higher. http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.6&r2=1.331.2.13.2.7&diff_format=u Index: php-src/ext/pgsql/pgsql.c diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.6 php-src/ext/pgsql/pgsql.c:1.331.2.13.2.7 --- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.6 Tue Oct 3 15:21:47 2006 +++ php-src/ext/pgsql/pgsql.c Wed Oct 4 23:27:03 2006 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.331.2.13.2.6 2006/10/03 15:21:47 bjori Exp $ */ +/* $Id: pgsql.c,v 1.331.2.13.2.7 2006/10/04 23:27:03 iliaa Exp $ */ #include <stdlib.h> @@ -3547,20 +3547,36 @@ /* }}} */ #ifdef HAVE_PQESCAPE -/* {{{ proto string pg_escape_string(string data) +/* {{{ proto string pg_escape_string([resource connection,] string data) Escape string for text/char type */ PHP_FUNCTION(pg_escape_string) { char *from = NULL, *to = NULL; + zval *pgsql_link; + PGconn *pgsql; int to_len; int from_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", - &from, &from_len) == FAILURE) { - return; + int id; + + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pgsql_link, &from, &from_len) == SUCCESS) { + id = -1; + } else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &from, &from_len) == SUCCESS) { + pgsql_link = NULL; + id = PGG(default_link); + } else { + WRONG_PARAM_COUNT; } - to = (char *)safe_emalloc(from_len, 2, 1); - to_len = (int)PQescapeString(to, from, from_len); + to = (char *) safe_emalloc(from_len, 2, 1); + +#ifdef HAVE_PQESCAPE_CONN + if (pgsql_link != NULL || id != -1) { + ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); + to_len = (int) PQescapeStringConn(pgsql, to, from, (size_t)from_len, NULL); + } else +#endif + to_len = (int) PQescapeString(to, from, (size_t)from_len); + RETURN_STRINGL(to, to_len, 0); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/config.m4?r1=1.46.2.1.2.1&r2=1.46.2.1.2.2&diff_format=u Index: php-src/ext/pgsql/config.m4 diff -u php-src/ext/pgsql/config.m4:1.46.2.1.2.1 php-src/ext/pgsql/config.m4:1.46.2.1.2.2 --- php-src/ext/pgsql/config.m4:1.46.2.1.2.1 Fri Sep 15 19:47:50 2006 +++ php-src/ext/pgsql/config.m4 Wed Oct 4 23:27:03 2006 @@ -1,5 +1,5 @@ dnl -dnl $Id: config.m4,v 1.46.2.1.2.1 2006/09/15 19:47:50 iliaa Exp $ +dnl $Id: config.m4,v 1.46.2.1.2.2 2006/10/04 23:27:03 iliaa Exp $ dnl AC_DEFUN([PHP_PGSQL_CHECK_FUNCTIONS],[ @@ -91,6 +91,7 @@ AC_CHECK_LIB(pq, PQgetCopyData,AC_DEFINE(HAVE_PQGETCOPYDATA,1,[PostgreSQL 7.4 or later])) AC_CHECK_LIB(pq, PQsetErrorVerbosity,AC_DEFINE(HAVE_PQSETERRORVERBOSITY,1,[PostgreSQL 7.4 or later])) AC_CHECK_LIB(pq, PQftable,AC_DEFINE(HAVE_PQFTABLE,1,[PostgreSQL 7.4 or later])) + AC_CHECK_LIB(pq, PQescapeStringConn, AC_DEFINE(HAVE_PQESCAPE_CONN,1,[PostgreSQL 8.1 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 LDFLAGS=$old_LDFLAGS http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.284&r2=1.2027.2.547.2.285&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.284 php-src/NEWS:1.2027.2.547.2.285 --- php-src/NEWS:1.2027.2.547.2.284 Wed Oct 4 23:19:25 2006 +++ php-src/NEWS Wed Oct 4 23:27:03 2006 @@ -3,6 +3,8 @@ ?? Sep 2006, PHP 5.2.0 - Speedup array/HashTable copying. (Matt W, Dmitry) - Added ability to make SOAP call userspace PHP<->XML converters. (Dmitry) +- Added support for character sets in pg_escape_string() for PostgreSQL + 8.1.4 and higher. (Ilia) - Fixed infinite loop when a wrong color index is given to imagefill (Pierre) - Fixed mess with CGI/CLI -d option (now it works with cgi; constants are working exactly like in php.ini; with FastCGI -d affects all requests).
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php