Date: 01/03/01
- Next message: djcris1 <email protected>: "[PHP-DEV] Get the lifestyle you want!!! 18876"
- Previous message: sniper <email protected>: "[PHP-DEV] PHP 4.0 Bug #8543 Updated: in memory PDF's ERROR"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The other day someone on the pgsql-general list was saying that
it was asked if there was anything that PHP needed to further
support Postgres. Luckily, I had just completed the following
additions for a local project.
This adds the pg_lolseek() call, which allows for arbitrary
seeking within a large object, and the pg_lotell call,
which can be used to find the current file offset for a
large object. They've been lightly tested, but are fairly
simple...
Warning: This should probably be looked over by someone with
more clues then me, as this is my first addition to PHP.
...let me know if they work or if there is anything wrong
with this patch...
? patch
? lo-patch.diff
Index: pgsql.c
===================================================================
RCS file: /repository/php4/ext/pgsql/pgsql.c,v
retrieving revision 1.81
diff -c -r1.81 pgsql.c
*** pgsql.c 2000/12/13 12:26:25 1.81
--- pgsql.c 2001/01/04 01:37:17
***************
*** 75,80 ****
--- 75,82 ----
PHP_FE(pg_loreadall, NULL)
PHP_FE(pg_loimport, NULL)
PHP_FE(pg_loexport, NULL)
+ PHP_FE(pg_lolseek, NULL)
+ PHP_FE(pg_lotell, NULL)
PHP_FE(pg_put_line, NULL)
PHP_FE(pg_end_copy, NULL)
#if HAVE_PQCLIENTENCODING
***************
*** 1733,1738 ****
--- 1735,1795 ----
} else {
RETURN_FALSE;
}
+ }
+ /* }}} */
+
+ /* {{{ proto int pg_lolseek(int objoid, int offset, int whence)
+ Seek into a postgres large object*/
+ PHP_FUNCTION(pg_lolseek) {
+ zval **pgsql_lofp, **seek_offset, **seek_whence;
+ pgLofp *pgsql;
+
+ switch(ZEND_NUM_ARGS()) {
+ case 3:
+ if (zend_get_parameters_ex(3, &pgsql_lofp, &seek_offset, &seek_whence)==FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_long_ex(seek_offset);
+ convert_to_long_ex(seek_whence);
+ break;
+ default:
+ WRONG_PARAM_COUNT;
+ break;
+ }
+
+ ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_lofp, -1, "PostgreSQL large object", le_lofp);
+
+ if (lo_lseek((PGconn *)pgsql->conn, pgsql->lofd, Z_STRVAL_PP(seek_offset), Z_STRVAL_PP(seek_whence))) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+ }
+ /* }}} */
+
+ /* {{{ proto int pg_tell(int objoid)
+ return current offset into large object */
+ PHP_FUNCTION(pg_lotell) {
+ long int offset;
+ zval **pgsql_lofp;
+ pgLofp *pgsql;
+
+ switch(ZEND_NUM_ARGS()) {
+ case 1:
+ if (zend_get_parameters_ex(1, &pgsql_lofp)==FAILURE) {
+ RETURN_FALSE;
+ }
+ break;
+ default:
+ WRONG_PARAM_COUNT;
+ break;
+ }
+
+ ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_lofp, -1, "PostgreSQL large object", le_lofp);
+
+ offset = lo_tell((PGconn *)pgsql->conn, pgsql->lofd);
+ return_value->value.lval = offset;
+ return_value->type = IS_LONG;
}
/* }}} */
Index: php_pgsql.h
===================================================================
RCS file: /repository/php4/ext/pgsql/php_pgsql.h,v
retrieving revision 1.22
diff -c -r1.22 php_pgsql.h
*** php_pgsql.h 2000/09/13 04:13:36 1.22
--- php_pgsql.h 2001/01/04 01:37:17
***************
*** 85,90 ****
--- 85,92 ----
PHP_FUNCTION(pg_loreadall);
PHP_FUNCTION(pg_loimport);
PHP_FUNCTION(pg_loexport);
+ PHP_FUNCTION(pg_lolseek);
+ PHP_FUNCTION(pg_lotell);
PHP_FUNCTION(pg_put_line);
PHP_FUNCTION(pg_end_copy);
#if HAVE_PQCLIENTENCODING
-- Adam Haberlach |A cat spends her life conflicted between a adam <email protected> |deep, passionate, and profound desire for http://www.newsnipple.com |fish and an equally deep, passionate, and '88 EX500 |profound desire to avoid getting wet.-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: djcris1 <email protected>: "[PHP-DEV] Get the lifestyle you want!!! 18876"
- Previous message: sniper <email protected>: "[PHP-DEV] PHP 4.0 Bug #8543 Updated: in memory PDF's ERROR"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

