CVS update: php3/functions

From: Date: Mon, 28 Sep 1998 15:39:43 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-1537@lists.php.net to get a copy of this message
Date: Monday September 28, 1998 @ 11:39 Author: ssb Update of /repository/php3/functions In directory asf:/u2/tmp/cvs-serv691 Modified Files: oci8.c php3_oci8.h Log Message: both SELECT and other statements work again Index: php3/functions/oci8.c diff -c php3/functions/oci8.c:1.16 php3/functions/oci8.c:1.17 *** php3/functions/oci8.c:1.16 Wed Sep 23 09:47:24 1998 --- php3/functions/oci8.c Mon Sep 28 11:39:41 1998 *************** *** 30,36 **** +----------------------------------------------------------------------+ */ ! /* $Id: oci8.c,v 1.16 1998/09/23 13:47:24 ssb Exp $ */ #include "php.h" #include "internal_functions.h" --- 30,36 ---- +----------------------------------------------------------------------+ */ ! /* $Id: oci8.c,v 1.17 1998/09/28 15:39:41 ssb Exp $ */ #include "php.h" #include "internal_functions.h" *************** *** 161,166 **** --- 161,167 ---- void php3_oci8_fetchinto(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_serverversion(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_bindbyname(INTERNAL_FUNCTION_PARAMETERS); + void php3_oci8_statementtype(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_test(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_test2(INTERNAL_FUNCTION_PARAMETERS); *************** *** 186,191 **** --- 187,193 ---- {"ocifetchinto", php3_oci8_fetchinto, second_arg_force_ref}, {"ociserverversion", php3_oci8_serverversion, NULL}, {"ocibindbyname", php3_oci8_bindbyname, refs_aaf}, + {"ocistatementtype", php3_oci8_statementtype, NULL}, {"ocitest", php3_oci8_test, first_arg_force_ref}, {"ocitest2", php3_oci8_test2, NULL}, {NULL, NULL, NULL} *************** *** 596,615 **** int counter; sword error, def_error; ub2 define_type; ! ub4 fncode = 0, iters, mode; OCI8_TLS_VARS; ! OCIAttrGet((dvoid *)statement, OCI_HTYPE_STMT, ! (dvoid *)&fncode, (ub4 *)0, OCI_ATTR_SQLFNCODE, statement->pError); ! if (fncode == FT_SELECT) { iters = 0; } else { iters = 1; } mode = OCI_COMMIT_ON_SUCCESS; ! oci8_debug("oci8_execute: fncode=%d mode=%d", fncode, mode); error = OCIStmtExecute(statement->conn->pServiceContext, statement->pStmt, statement->pError, iters, 0, NULL, NULL, mode); --- 598,618 ---- int counter; sword error, def_error; ub2 define_type; ! ub2 stmttype = 0; ! ub4 iters, mode; OCI8_TLS_VARS; ! OCIAttrGet((dvoid *)statement->pStmt, OCI_HTYPE_STMT, ! (ub2 *)&stmttype, (ub4 *)0, OCI_ATTR_STMT_TYPE, statement->pError); ! if (stmttype == OCI_STMT_SELECT) { iters = 0; } else { iters = 1; } mode = OCI_COMMIT_ON_SUCCESS; ! oci8_debug("oci8_execute: stmttype=%d mode=%d", stmttype, mode); error = OCIStmtExecute(statement->conn->pServiceContext, statement->pStmt, statement->pError, iters, 0, NULL, NULL, mode); *************** *** 627,633 **** return 0; } ! if (fncode == FT_SELECT) { OCIHandleAlloc(statement->conn->pEnv, (dvoid **)&param, OCI_DTYPE_PARAM, 0, NULL); counter = 1; --- 630,636 ---- return 0; } ! if (stmttype == OCI_STMT_SELECT) { OCIHandleAlloc(statement->conn->pEnv, (dvoid **)&param, OCI_DTYPE_PARAM, 0, NULL); counter = 1; *************** *** 1431,1436 **** --- 1434,1502 ---- oci8_bind_out_callback ); RETVAL_TRUE; + } + + /* }}} */ + /* {{{ int OCIStatementType(int stmt) */ + + /* XXX it would be better with a general interface to OCIAttrGet() */ + + void php3_oci8_statementtype(INTERNAL_FUNCTION_PARAMETERS) + { + pval *stmt; + oci8_statement *statement; + ub2 stmttype; + sword error; + OCI8_TLS_VARS; + + if (getParameters(ht, 1, &stmt) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_long(stmt); + statement = oci8_get_stmt(stmt->value.lval, "OCIStatementType", list); + if (statement == NULL) { + RETURN_FALSE; + } + + error = OCIAttrGet((dvoid *)statement->pStmt, OCI_HTYPE_STMT, + (ub2 *)&stmttype, (ub4 *)0, OCI_ATTR_STMT_TYPE, + statement->pError); + if (error != OCI_SUCCESS) { + oci8_error(statement->pError, "OCIStatementType", error); + RETURN_FALSE; + } + + switch (stmttype) { + case OCI_STMT_SELECT: + RETVAL_STRING("SELECT",1); + break; + case OCI_STMT_UPDATE: + RETVAL_STRING("UPDATE",1); + break; + case OCI_STMT_DELETE: + RETVAL_STRING("DELETE",1); + break; + case OCI_STMT_INSERT: + RETVAL_STRING("INSERT",1); + break; + case OCI_STMT_CREATE: + RETVAL_STRING("CREATE",1); + break; + case OCI_STMT_DROP: + RETVAL_STRING("DROP",1); + break; + case OCI_STMT_ALTER: + RETVAL_STRING("ALTER",1); + break; + case OCI_STMT_BEGIN: + RETVAL_STRING("BEGIN",1); + break; + case OCI_STMT_DECLARE: + RETVAL_STRING("DECLARE",1); + break; + default: + RETVAL_STRING("UNKNOWN",1); + } } /* }}} */ Index: php3/functions/php3_oci8.h diff -c php3/functions/php3_oci8.h:1.11 php3/functions/php3_oci8.h:1.12 *** php3/functions/php3_oci8.h:1.11 Mon Sep 14 07:59:22 1998 --- php3/functions/php3_oci8.h Mon Sep 28 11:39:41 1998 *************** *** 51,62 **** # include <oci.h> - /* some SQL function codes */ - #define FT_INSERT 3 - #define FT_SELECT 4 - #define FT_UPDATE 5 - #define FT_DELETE 9 - # if 0 typedef struct { OCIEnv *pEnv; --- 51,56 ---- -- 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 (#1537) next »