diff options
author | Markus Fischer <mfischer@php.net> | 2002-03-18 21:01:29 +0000 |
---|---|---|
committer | Markus Fischer <mfischer@php.net> | 2002-03-18 21:01:29 +0000 |
commit | 30454e237b997ef9179a7aa4e0c6c44aecd46d70 (patch) | |
tree | cf4a4e3f7dd39e4aead1407e21e75b30608f9c41 | |
parent | e3a884f5525b96a0cd4d5f42b94922c17850406e (diff) | |
download | php-git-30454e237b997ef9179a7aa4e0c6c44aecd46d70.tar.gz |
- Let OCIError() also return the sql statement which failed and the exact
position into the statement where it failed (if applicable).
Patch by Daniel Ceregatti <vi@sh.nu>.
-rw-r--r-- | ext/oci8/oci8.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 988b4bc5d5..baccacd562 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -4218,16 +4218,35 @@ PHP_FUNCTION(ocierror) zval **arg; oci_statement *statement; oci_connection *connection; - text errbuf[512]; - sb4 errcode = 0; + text errbuf[512]; + sb4 errcode = 0; sword error = 0; dvoid *errh = NULL; + ub2 errorofs = 0; + text *sqltext = NULL; if (zend_get_parameters_ex(1, &arg) == SUCCESS) { statement = (oci_statement *) zend_fetch_resource(arg TSRMLS_CC, -1, NULL, NULL, 1, le_stmt); if (statement) { errh = statement->pError; error = statement->error; + + CALL_OCI_RETURN(statement->error, OCIAttrGet( + (dvoid *)statement->pStmt, + OCI_HTYPE_STMT, + (text *) &sqltext, + (ub4 *)0, + OCI_ATTR_STATEMENT, + statement->pError)); + + CALL_OCI_RETURN(statement->error, OCIAttrGet( + (dvoid *)statement->pStmt, + OCI_HTYPE_STMT, + (ub2 *)&errorofs, + (ub4 *)0, + OCI_ATTR_PARSE_ERROR_OFFSET, + statement->pError)); + } else { connection = (oci_connection *) zend_fetch_resource(arg TSRMLS_CC, -1, NULL, NULL, 1, le_conn); if (connection) { @@ -4262,6 +4281,8 @@ PHP_FUNCTION(ocierror) array_init(return_value); add_assoc_long(return_value, "code", errcode); add_assoc_string(return_value, "message", (char*) errbuf, 1); + add_assoc_long(return_value, "offset", errorofs); + add_assoc_string(return_value, "sqltext", sqltext ? (char *) sqltext : "", 1); } else { RETURN_FALSE; } |