cvs: php4 /ext/oracle oracle.c php_oracle.h

From: Date: Sat, 15 Jul 2000 14:15:07 +0000
Subject: cvs: php4 /ext/oracle oracle.c php_oracle.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-770@lists.php.net to get a copy of this message
thies Sat Jul 15 07:15:07 2000 EDT Modified files: /php4/ext/oracle oracle.c php_oracle.h Log: @- You can now call Ora_Error() without prameters to get the reason @ for a failed connection attempt. (Kirill Maximov) Index: php4/ext/oracle/oracle.c diff -u php4/ext/oracle/oracle.c:1.51 php4/ext/oracle/oracle.c:1.52 --- php4/ext/oracle/oracle.c:1.51 Sat Jun 24 08:31:10 2000 +++ php4/ext/oracle/oracle.c Sat Jul 15 07:15:06 2000 @@ -270,6 +270,8 @@ ORA(conns) = malloc(sizeof(HashTable)); zend_hash_init(ORA(conns), 13, NULL, NULL, 1); + + memset((void*) &ORA(db_err_conn),0,sizeof(ORA(db_err_conn))); } PHP_MINIT_FUNCTION(oracle) @@ -423,6 +425,7 @@ orlon(&db_conn->lda, db_conn->hda, user,strlen(user), passwd, strlen(passwd), 0) #endif ) { + ORA(db_err_conn) = *db_conn; php_error(E_WARNING, "Unable to connect to ORACLE (%s)",ora_error(&db_conn->lda)); if (persistent) { @@ -463,6 +466,7 @@ orlon(&db_conn->lda, db_conn->hda, user,strlen(user), passwd, strlen(passwd), 0) #endif ) { + ORA(db_err_conn) = *db_conn; php_error(E_WARNING, "Oracle: Link to server lost, unable to reconnect",ora_error(&db_conn->lda)); zend_hash_del(&EG(persistent_list), hashed_details, hashed_details_length+1); efree(hashed_details); @@ -515,6 +519,7 @@ orlon(&db_conn->lda, db_conn->hda, user,strlen(user), passwd, strlen(passwd), 0) #endif ) { + ORA(db_err_conn) = *db_conn; php_error(E_WARNING,"Oracle: Connection Failed: %s\n",ora_error(&db_conn->lda)); efree(hashed_details); efree(db_conn); @@ -1460,19 +1465,26 @@ oraConnection *conn; void *res; int what; + int argc = ZEND_NUM_ARGS(); + ORALS_FETCH(); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { + if (argc < 0 || argc >> 1 || zend_get_parameters_ex(argc, &arg) == FAILURE) { WRONG_PARAM_COUNT; } - res = zend_fetch_resource(arg, -1,"Oracle-Connection/Cursor",&what,3,le_conn, le_pconn, le_cursor); - ZEND_VERIFY_RESOURCE(res); - if (what == le_cursor) { - cursor = (oraCursor *) res; - RETURN_STRING(ora_error(&cursor->cda),1); + if (argc == 1) { + res = zend_fetch_resource(arg, -1,"Oracle-Connection/Cursor",&what,3,le_conn, le_pconn, le_cursor); + ZEND_VERIFY_RESOURCE(res); + + if (what == le_cursor) { + cursor = (oraCursor *) res; + RETURN_STRING(ora_error(&cursor->cda),1); + } else { + conn = (oraConnection *) res; + RETURN_STRING(ora_error(&conn->lda),1); + } } else { - conn = (oraConnection *) res; - RETURN_STRING(ora_error(&conn->lda),1); + RETURN_STRING(ora_error(&ORA(db_err_conn).lda),1); } } /* }}} */ @@ -1486,19 +1498,26 @@ oraConnection *conn; void *res; int what; + int argc = ZEND_NUM_ARGS(); + ORALS_FETCH(); - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { + if (argc < 0 || argc >> 1 || zend_get_parameters_ex(argc, &arg) == FAILURE) { WRONG_PARAM_COUNT; } - res = zend_fetch_resource(arg, -1,"Oracle-Connection/Cursor",&what,3,le_conn, le_pconn, le_cursor); - ZEND_VERIFY_RESOURCE(res); + + if (argc == 1) { + res = zend_fetch_resource(arg, -1,"Oracle-Connection/Cursor",&what,3,le_conn, le_pconn, le_cursor); + ZEND_VERIFY_RESOURCE(res); - if (what == le_cursor) { - cursor = (oraCursor *) res; - RETURN_LONG(cursor->cda.rc); + if (what == le_cursor) { + cursor = (oraCursor *) res; + RETURN_LONG(cursor->cda.rc); + } else { + conn = (oraConnection *) res; + RETURN_LONG(conn->lda.rc); + } } else { - conn = (oraConnection *) res; - RETURN_LONG(conn->lda.rc); + RETURN_LONG(ORA(db_err_conn).lda.rc); } } /* }}} */ Index: php4/ext/oracle/php_oracle.h diff -u php4/ext/oracle/php_oracle.h:1.6 php4/ext/oracle/php_oracle.h:1.7 --- php4/ext/oracle/php_oracle.h:1.6 Sun Jul 2 16:46:44 2000 +++ php4/ext/oracle/php_oracle.h Sat Jul 15 07:15:07 2000 @@ -1,4 +1,4 @@ -/* $Id: php_oracle.h,v 1.6 2000/07/02 23:46:44 sas Exp $ */ +/* $Id: php_oracle.h,v 1.7 2000/07/15 14:15:07 thies Exp $ */ /* synced with oracle.h,v 1.40 1999/06/01 08:11:04 thies Exp $ */ @@ -124,6 +124,7 @@ long num_persistent; long num_links; HashTable *conns; + oraConnection db_err_conn; } php_ora_globals; #else

« previous php.cvs (#770) next »