CVS update: php3/functions

From: Date: Fri, 09 Oct 1998 15:04:15 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-1760@lists.php.net to get a copy of this message
Date: Friday October 9, 1998 @ 11:04 Author: ssb Update of /repository/php3/functions In directory asf:/u2/tmp/cvs-serv2371 Modified Files: unified_odbc.c Log Message: * workaround: OpenLink now always uses SQLDriverConnect() instead of SQLConnect(). * odbc_autocommit() without arguments now returns autocommit state. Index: php3/functions/unified_odbc.c diff -c php3/functions/unified_odbc.c:1.81 php3/functions/unified_odbc.c:1.82 *** php3/functions/unified_odbc.c:1.81 Sat Oct 3 16:48:40 1998 --- php3/functions/unified_odbc.c Fri Oct 9 11:04:14 1998 *************** *** 261,269 **** UODBC_GLOBAL(PHP3_UODBC_MODULE).max_links = -1; } #else ! UODBC_GLOBAL(PHP3_UODBC_MODULE).allow_persistent = -1; ! UODBC_GLOBAL(PHP3_UODBC_MODULE).max_persistent = -1; ! UODBC_GLOBAL(PHP3_UODBC_MODULE).max_links = -1; #endif UODBC_GLOBAL(PHP3_UODBC_MODULE).num_persistent = 0; --- 261,269 ---- UODBC_GLOBAL(PHP3_UODBC_MODULE).max_links = -1; } #else ! UODBC_GLOBAL(PHP3_UODBC_MODULE).allow_persistent = -1; ! UODBC_GLOBAL(PHP3_UODBC_MODULE).max_persistent = -1; ! UODBC_GLOBAL(PHP3_UODBC_MODULE).max_links = -1; #endif UODBC_GLOBAL(PHP3_UODBC_MODULE).num_persistent = 0; *************** *** 456,469 **** SWORD errormsgsize; /* Not used */ UODBC_TLS_VARS; ! SQLError(UODBC_GLOBAL(PHP3_UODBC_MODULE).henv, conn, stmt, state, &error, errormsg, ! sizeof(errormsg)-1, &errormsgsize); ! ! if (func) ! php3_error(E_WARNING, "SQL error: %s, SQL state %s in %s", errormsg, ! state, func); ! else ! php3_error(E_WARNING, "SQL error: %s, SQL state %s", errormsg, state); } /* Main User Functions */ --- 456,470 ---- SWORD errormsgsize; /* Not used */ UODBC_TLS_VARS; ! SQLError(UODBC_GLOBAL(PHP3_UODBC_MODULE).henv, conn, stmt, state, ! &error, errormsg, sizeof(errormsg)-1, &errormsgsize); ! if (func) { ! php3_error(E_WARNING, "SQL error: %s, SQL state %s in %s", ! errormsg, state, func); ! } else { ! php3_error(E_WARNING, "SQL error: %s, SQL state %s", ! errormsg, state); ! } } /* Main User Functions */ *************** *** 661,667 **** void PHP3_UODBC_EXECUTE(INTERNAL_FUNCTION_PARAMETERS) { pval *arg1, *arg2, arr, *tmp; ! typedef struct params_t{ SDWORD vallen; int fp; } params_t; --- 662,668 ---- void PHP3_UODBC_EXECUTE(INTERNAL_FUNCTION_PARAMETERS) { pval *arg1, *arg2, arr, *tmp; ! typedef struct params_t { SDWORD vallen; int fp; } params_t; *************** *** 712,718 **** _php3_hash_internal_pointer_reset(arr.value.ht); params = (params_t *)emalloc(sizeof(params_t) * result->numparams); ! for(i = 1; i <= result->numparams; i++){ if (_php3_hash_get_current_data(arr.value.ht, (void **) &tmp) == FAILURE) { php3_error(E_WARNING,"Error getting parameter"); SQLFreeStmt(result->stmt,SQL_RESET_PARAMS); --- 713,719 ---- _php3_hash_internal_pointer_reset(arr.value.ht); params = (params_t *)emalloc(sizeof(params_t) * result->numparams); ! for (i = 1; i <= result->numparams; i++) { if (_php3_hash_get_current_data(arr.value.ht, (void **) &tmp) == FAILURE) { php3_error(E_WARNING,"Error getting parameter"); SQLFreeStmt(result->stmt,SQL_RESET_PARAMS); *************** *** 720,761 **** RETURN_FALSE; } convert_to_string(tmp); ! if (tmp->type != IS_STRING){ php3_error(E_WARNING,"Error converting parameter"); ! SQLFreeStmt(result->stmt,SQL_RESET_PARAMS); _php3_hash_destroy(arr.value.ht); efree(arr.value.ht); efree(params); RETURN_FALSE; } ! SQLDescribeParam(result->stmt,(UWORD)i,&sqltype,&precision,&scale,&nullable); params[i-1].vallen = tmp->value.str.len; params[i-1].fp = -1; ! if (tmp->value.str.val[0] == '\''){ filename = &tmp->value.str.val[1]; filename[tmp->value.str.len - 2] = '\0'; ! if ((params[i-1].fp = open(filename,O_RDONLY)) == -1){ ! php3_error(E_WARNING,"Can´t open file %s",filename); ! SQLFreeStmt(result->stmt,SQL_RESET_PARAMS); ! for(i = 0; i < result->numparams; i++){ ! if (params[i].fp != -1) close(params[i].fp); } _php3_hash_destroy(arr.value.ht); efree(arr.value.ht); efree(params); RETURN_FALSE; ! } params[i-1].vallen = SQL_LEN_DATA_AT_EXEC(0); rc = SQLBindParameter(result->stmt, (UWORD)i, SQL_PARAM_INPUT, ! SQL_C_BINARY, sqltype, precision, scale, ! (void *)params[i-1].fp, 0, &params[i-1].vallen); } else { /*if (IS_SQL_BINARY(sqltype)){ php3_error(E_WARNING,"No Filename for binary parameter"); --- 721,765 ---- RETURN_FALSE; } convert_to_string(tmp); ! if (tmp->type != IS_STRING) { php3_error(E_WARNING,"Error converting parameter"); ! SQLFreeStmt(result->stmt, SQL_RESET_PARAMS); _php3_hash_destroy(arr.value.ht); efree(arr.value.ht); efree(params); RETURN_FALSE; } ! SQLDescribeParam(result->stmt, (UWORD)i, &sqltype, &precision, ! &scale, &nullable); params[i-1].vallen = tmp->value.str.len; params[i-1].fp = -1; ! if (tmp->value.str.val[0] == '\'') { filename = &tmp->value.str.val[1]; filename[tmp->value.str.len - 2] = '\0'; ! if ((params[i-1].fp = open(filename,O_RDONLY)) == -1) { ! php3_error(E_WARNING,"Can't open file %s", filename); ! SQLFreeStmt(result->stmt, SQL_RESET_PARAMS); ! for (i = 0; i < result->numparams; i++) { ! if (params[i].fp != -1) { close(params[i].fp); + } } _php3_hash_destroy(arr.value.ht); efree(arr.value.ht); efree(params); RETURN_FALSE; ! } params[i-1].vallen = SQL_LEN_DATA_AT_EXEC(0); rc = SQLBindParameter(result->stmt, (UWORD)i, SQL_PARAM_INPUT, ! SQL_C_BINARY, sqltype, precision, scale, ! (void *)params[i-1].fp, 0, ! &params[i-1].vallen); } else { /*if (IS_SQL_BINARY(sqltype)){ php3_error(E_WARNING,"No Filename for binary parameter"); *************** *** 767,774 **** } */ rc = SQLBindParameter(result->stmt, (UWORD)i, SQL_PARAM_INPUT, ! SQL_C_CHAR, sqltype, precision, scale, ! tmp->value.str.val, 0, &params[i-1].vallen); } _php3_hash_move_forward(arr.value.ht); } --- 771,779 ---- } */ rc = SQLBindParameter(result->stmt, (UWORD)i, SQL_PARAM_INPUT, ! SQL_C_CHAR, sqltype, precision, scale, ! tmp->value.str.val, 0, ! &params[i-1].vallen); } _php3_hash_move_forward(arr.value.ht); } *************** *** 1653,1659 **** --- 1658,1675 ---- SQLSetConnectOption(db_conn->hdbc, SQL_TRANSLATE_OPTION, SQL_SOLID_XLATOPT_NOCNV); #endif + #if HAVE_OPENLINK + { + char dsnbuf[300]; + short dsnbuflen; + + rc = SQLDriverConnect(db_conn->hdbc, NULL, db, SQL_NTS, + dsnbuf, sizeof(dsnbuf)-1, &dsnbuflen, + SQL_DRIVER_COMPLETE); + } + #else rc = SQLConnect(db_conn->hdbc, db, SQL_NTS, uid, SQL_NTS, pwd, SQL_NTS); + #endif if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { UODBC_SQL_ERROR(db_conn->hdbc, SQL_NULL_HSTMT, "SQLConnect"); *************** *** 1942,1969 **** { UODBC_CONNECTION *curr_conn; RETCODE rc; ! pval *arg1, *arg2; ! if ( getParameters(ht, 2, &arg1, &arg2) == FAILURE) { WRONG_PARAM_COUNT; ! } convert_to_long(arg1); ! convert_to_long(arg2); ! ! if ((curr_conn = UODBC_GET_CONN(list, arg1->value.lval)) == NULL){ ! RETURN_FALSE; } ! rc = SQLSetConnectOption(curr_conn->hdbc, SQL_AUTOCOMMIT, ! (arg2->value.lval) ? ! SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF); ! if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){ ! UODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "Autocommit"); RETURN_FALSE; } ! RETURN_TRUE; } void PHP3_UODBC_TRANSACT(INTERNAL_FUNCTION_PARAMETERS, int type) --- 1958,2007 ---- { UODBC_CONNECTION *curr_conn; RETCODE rc; ! pval *arg1, *arg2 = NULL; ! int argc; ! argc = ARG_COUNT(ht); ! if (argc == 2) { ! if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) { ! WRONG_PARAM_COUNT; ! } ! } else if (argc == 1) { ! if (getParameters(ht, 1, &arg1) == FAILURE) { ! WRONG_PARAM_COUNT; ! } ! } else { WRONG_PARAM_COUNT; ! } convert_to_long(arg1); ! if (arg2) { ! convert_to_long(arg2); } ! if ((curr_conn = UODBC_GET_CONN(list, arg1->value.lval)) == NULL) { RETURN_FALSE; } ! if (arg2) { ! rc = SQLSetConnectOption(curr_conn->hdbc, SQL_AUTOCOMMIT, ! (arg2->value.lval) ? ! SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF); ! if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){ ! UODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "Set autocommit"); ! RETURN_FALSE; ! } ! RETVAL_TRUE; ! } else { ! SDWORD status; ! ! rc = SQLGetConnectOption(curr_conn->hdbc, SQL_AUTOCOMMIT, &status); ! if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO){ ! UODBC_SQL_ERROR(curr_conn->hdbc, SQL_NULL_HSTMT, "Test autocommit"); ! RETURN_FALSE; ! } ! RETVAL_LONG((long)status); ! } } void PHP3_UODBC_TRANSACT(INTERNAL_FUNCTION_PARAMETERS, int type) -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#1760) next »