cvs: /php3/functions oci8.c
| From: | Andreas Karajannis | Date: | Wed, 04 Aug 1999 18:23:59 +0000 |
| Subject: | cvs: /php3/functions oci8.c | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-9507@lists.php.net to get a copy of this message | ||
kara Wed Aug 4 14:23:59 1999 EDT
Modified files:
/php3/functions oci8.c
Log:
Added direct upload of LOBS from file to oci8_savedesc
Index: php3/functions/oci8.c
diff -u php3/functions/oci8.c:1.115 php3/functions/oci8.c:1.116
--- php3/functions/oci8.c:1.115 Mon Jul 12 07:51:41 1999
+++ php3/functions/oci8.c Wed Aug 4 14:23:57 1999
@@ -33,7 +33,7 @@
#define OCI8_USE_EMALLOC 0 /* set this to 1 if you want to use the php memory manager! */
-/* $Id: oci8.c,v 1.115 1999/07/12 11:51:41 thies Exp $ */
+/* $Id: oci8.c,v 1.116 1999/08/04 18:23:57 kara Exp $ */
/* TODO list:
*
@@ -2613,16 +2613,54 @@
WRONG_PARAM_COUNT;
}
- loblen = arg->value.str.len;
+ if(arg->value.str.val[0] == '\'') {
+ char buf[8192];
+ int fp;
+ ub4 offset = 1;
+ char *filename;
+
+ /* read directly from file */
+ filename = &arg->value.str.val[1];
+
+ filename[arg->value.str.len - 2] = '\0';
+ if ((fp = open(filename, O_RDONLY)) == -1) {
+ php3_error(E_WARNING, "Can't open file %s", filename);
+ RETURN_FALSE;
+ }
+ while((loblen = read(fp, &buf, 8192)) > 0){
+ connection->error =
+ OCILobWrite(connection->pServiceContext,
+ connection->pError,
+ mylob,
+ &loblen,
+ offset,
+ (dvoid *) &buf,
+ (ub4) loblen,
+ OCI_ONE_PIECE,
+ (dvoid *)0,
+ (OCICallbackLobWrite) 0,
+ (ub2) 0,
+ (ub1) SQLCS_IMPLICIT
+ );
+ if (connection->error) {
+ oci8_error(connection->pError, "OCILobWrite", connection->error);
+ close(fp);
+ RETURN_FALSE;
+ }
+ offset += loblen;
+ }
+ close(fp);
+ }else{
+ loblen = arg->value.str.len;
- if (loblen < 1) {
- php3_error(E_WARNING, "Cannot save a lob wich size is less than 1 byte");
- RETURN_FALSE;
- }
+ if (loblen < 1) {
+ php3_error(E_WARNING, "Cannot save a lob wich size is less than 1 byte");
+ RETURN_FALSE;
+ }
- connection->error =
- OCILobWrite(connection->pServiceContext,
+ connection->error =
+ OCILobWrite(connection->pServiceContext,
connection->pError,
mylob,
&loblen,
@@ -2635,13 +2673,13 @@
(ub2) 0,
(ub1) SQLCS_IMPLICIT );
- oci8_debug("OCIsavedesc: size=%d",loblen);
+ oci8_debug("OCIsavedesc: size=%d",loblen);
- if (connection->error) {
- oci8_error(connection->pError, "OCILobWrite", connection->error);
- RETURN_FALSE;
+ if (connection->error) {
+ oci8_error(connection->pError, "OCILobWrite", connection->error);
+ RETURN_FALSE;
+ }
}
-
RETURN_TRUE;
}