cvs: php4 /ext/pgsql pgsql.c php_pgsql.h

From: Date: Mon, 11 Sep 2000 15:34:15 +0000
Subject: cvs: php4 /ext/pgsql pgsql.c php_pgsql.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-1707@lists.php.net to get a copy of this message
derick Mon Sep 11 08:34:15 2000 EDT Modified files: /php4/ext/pgsql pgsql.c php_pgsql.h Log: - Added functions pg_putline and pg_endcopy (thanks to Dirk Elmendorf <delmendo@rackspace.com>) @ Added functions pg_putline and pg_endcopy (Dirk Elmendorf) Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.68 php4/ext/pgsql/pgsql.c:1.69 --- php4/ext/pgsql/pgsql.c:1.68 Sat Sep 9 02:40:16 2000 +++ php4/ext/pgsql/pgsql.c Mon Sep 11 08:34:14 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.68 2000/09/09 09:40:16 jah Exp $ */ +/* $Id: pgsql.c,v 1.69 2000/09/11 15:34:14 derick Exp $ */ #include <stdlib.h> @@ -75,6 +75,8 @@ PHP_FE(pg_loreadall, NULL) PHP_FE(pg_loimport, NULL) PHP_FE(pg_loexport, NULL) + PHP_FE(pg_putline, NULL) + PHP_FE(pg_endcopy, NULL) #if HAVE_PQCLIENTENCODING PHP_FE(pg_clientencoding, NULL) PHP_FE(pg_setclientencoding, NULL) @@ -645,7 +647,91 @@ } } /* }}} */ +/* {{{ proto int pg_endcopy([int connection]) + Sync with backend. Completes the Copy command */ +PHP_FUNCTION(pg_endcopy) +{ + zval **query, **pgsql_link; + int id = -1; + PGconn *pgsql; + int result = 0; + ExecStatusType status; + pgsql_result_handle *pg_result; + PGLS_FETCH(); + + switch(ZEND_NUM_ARGS()) { + case 1: + if (zend_get_parameters_ex(1, &query)==FAILURE) { + RETURN_FALSE; + } + id = PGG(default_link); + break; + case 2: + if (zend_get_parameters_ex(2, &pgsql_link, &query)==FAILURE) { + RETURN_FALSE; + } + break; + default: + WRONG_PARAM_COUNT; + break; + } + + ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); + + convert_to_string_ex(query); + result = PQendcopy(pgsql); + +/* if (result!=0) + { + php_error(E_WARNING, "PostgreSQL query failed: %s", PQerrorMessage(pgsql)); + RETURN_FALSE; + } */ + RETURN_FALSE; +} +/* }}} */ +/* {{{ proto int pg_putline([int connection,] string query) + Send null-terminated string to backend server*/ +PHP_FUNCTION(pg_putline) +{ + zval **query, **pgsql_link; + int id = -1; + PGconn *pgsql; + int result = 0; + ExecStatusType status; + pgsql_result_handle *pg_result; + PGLS_FETCH(); + + switch(ZEND_NUM_ARGS()) { + case 1: + if (zend_get_parameters_ex(1, &query)==FAILURE) { + RETURN_FALSE; + } + id = PGG(default_link); + break; + case 2: + if (zend_get_parameters_ex(2, &pgsql_link, &query)==FAILURE) { + RETURN_FALSE; + } + break; + default: + WRONG_PARAM_COUNT; + break; + } + + ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); + + convert_to_string_ex(query); + result = PQputline(pgsql, Z_STRVAL_PP(query)); + + if (result==EOF) + { + php_error(E_WARNING, "PostgreSQL query failed: %s", PQerrorMessage(pgsql)); + RETURN_FALSE; + } + RETURN_FALSE; +} +/* }}} */ #define PHP_PG_NUM_ROWS 1 #define PHP_PG_NUM_FIELDS 2 #define PHP_PG_CMD_TUPLES 3 Index: php4/ext/pgsql/php_pgsql.h diff -u php4/ext/pgsql/php_pgsql.h:1.18 php4/ext/pgsql/php_pgsql.h:1.19 --- php4/ext/pgsql/php_pgsql.h:1.18 Fri Jul 28 21:24:11 2000 +++ php4/ext/pgsql/php_pgsql.h Mon Sep 11 08:34:14 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pgsql.h,v 1.18 2000/07/29 04:24:11 jah Exp $ */ +/* $Id: php_pgsql.h,v 1.19 2000/09/11 15:34:14 derick Exp $ */ #ifndef PHP_PGSQL_H #define PHP_PGSQL_H @@ -85,6 +85,8 @@ PHP_FUNCTION(pg_loreadall); PHP_FUNCTION(pg_loimport); PHP_FUNCTION(pg_loexport); +PHP_FUNCTION(pg_putline); +PHP_FUNCTION(pg_endcopy); #if HAVE_PQCLIENTENCODING PHP_FUNCTION(pg_clientencoding); PHP_FUNCTION(pg_setclientencoding);

« previous php.cvs (#1707) next »