2005-12-01 21:39:48 +08:00
|
|
|
|
/*
|
|
|
|
|
+----------------------------------------------------------------------+
|
2014-09-20 00:33:14 +08:00
|
|
|
|
| PHP Version 7 |
|
2005-12-01 21:39:48 +08:00
|
|
|
|
+----------------------------------------------------------------------+
|
2014-01-03 11:08:10 +08:00
|
|
|
|
| Copyright (c) 1997-2014 The PHP Group |
|
2005-12-01 21:39:48 +08:00
|
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 20:51:34 +08:00
|
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2005-12-01 21:39:48 +08:00
|
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 20:51:34 +08:00
|
|
|
|
| http://www.php.net/license/3_01.txt |
|
2005-12-01 21:39:48 +08:00
|
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
|
| Authors: Stig S<EFBFBD>ther Bakken <ssb@php.net> |
|
|
|
|
|
| Thies C. Arntzen <thies@thieso.net> |
|
|
|
|
|
| |
|
|
|
|
|
| Collection support by Andy Sautins <asautins@veripost.net> |
|
|
|
|
|
| Temporary LOB support by David Benson <dbenson@mancala.com> |
|
|
|
|
|
| ZTS per process OCIPLogon by Harald Radi <harald.radi@nme.at> |
|
|
|
|
|
| |
|
|
|
|
|
| Redesigned by: Antony Dovgal <antony@zend.com> |
|
|
|
|
|
| Andi Gutmans <andi@zend.com> |
|
|
|
|
|
| Wez Furlong <wez@omniti.com> |
|
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "php.h"
|
|
|
|
|
#include "ext/standard/info.h"
|
|
|
|
|
#include "php_ini.h"
|
|
|
|
|
|
2008-06-06 07:43:10 +08:00
|
|
|
|
#if HAVE_OCI8
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
#include "php_oci8.h"
|
|
|
|
|
#include "php_oci8_int.h"
|
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
/* {{{ php_oci_collection_create()
|
2005-12-01 21:39:48 +08:00
|
|
|
|
Create and return connection handle */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
php_oci_collection *php_oci_collection_create(php_oci_connection *connection, char *tdo, int tdo_len, char *schema, int schema_len TSRMLS_DC)
|
2005-12-01 21:39:48 +08:00
|
|
|
|
{
|
2008-02-16 07:24:45 +08:00
|
|
|
|
dvoid *dschp1 = NULL;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
dvoid *parmp1;
|
|
|
|
|
dvoid *parmp2;
|
|
|
|
|
php_oci_collection *collection;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
collection = emalloc(sizeof(php_oci_collection));
|
|
|
|
|
|
|
|
|
|
collection->connection = connection;
|
|
|
|
|
collection->collection = NULL;
|
2014-09-10 18:40:32 +08:00
|
|
|
|
++GC_REFCOUNT(collection->connection->id);
|
2007-08-01 03:21:08 +08:00
|
|
|
|
|
2005-12-01 21:39:48 +08:00
|
|
|
|
/* get type handle by name */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCITypeByName,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
connection->env,
|
|
|
|
|
connection->err,
|
|
|
|
|
connection->svc,
|
|
|
|
|
(text *) schema,
|
|
|
|
|
(ub4) schema_len,
|
|
|
|
|
(text *) tdo,
|
|
|
|
|
(ub4) tdo_len,
|
|
|
|
|
(CONST text *) 0,
|
|
|
|
|
(ub4) 0,
|
|
|
|
|
OCI_DURATION_SESSION,
|
|
|
|
|
OCI_TYPEGET_ALL,
|
|
|
|
|
&(collection->tdo)
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
2005-12-01 21:39:48 +08:00
|
|
|
|
goto CLEANUP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* allocate describe handle */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIHandleAlloc, (connection->env, (dvoid **) &dschp1, (ub4) OCI_HTYPE_DESCRIBE, (size_t) 0, (dvoid **) 0));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
2005-12-01 21:39:48 +08:00
|
|
|
|
goto CLEANUP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* describe TDO */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIDescribeAny,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
connection->svc,
|
|
|
|
|
connection->err,
|
|
|
|
|
(dvoid *) collection->tdo,
|
|
|
|
|
(ub4) 0,
|
|
|
|
|
OCI_OTYPE_PTR,
|
|
|
|
|
(ub1) OCI_DEFAULT,
|
|
|
|
|
(ub1) OCI_PTYPE_TYPE,
|
|
|
|
|
dschp1
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
2005-12-01 21:39:48 +08:00
|
|
|
|
goto CLEANUP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* get first parameter handle */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *) dschp1, (ub4) OCI_HTYPE_DESCRIBE, (dvoid *)&parmp1, (ub4 *)0, (ub4)OCI_ATTR_PARAM, connection->err));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
2005-12-01 21:39:48 +08:00
|
|
|
|
goto CLEANUP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* get the collection type code of the attribute */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
(dvoid*) parmp1,
|
|
|
|
|
(ub4) OCI_DTYPE_PARAM,
|
|
|
|
|
(dvoid*) &(collection->coll_typecode),
|
|
|
|
|
(ub4 *) 0,
|
|
|
|
|
(ub4) OCI_ATTR_COLLECTION_TYPECODE,
|
|
|
|
|
connection->err
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
2005-12-01 21:39:48 +08:00
|
|
|
|
goto CLEANUP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch(collection->coll_typecode) {
|
|
|
|
|
case OCI_TYPECODE_TABLE:
|
|
|
|
|
case OCI_TYPECODE_VARRAY:
|
|
|
|
|
/* get collection element handle */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
(dvoid*) parmp1,
|
|
|
|
|
(ub4) OCI_DTYPE_PARAM,
|
|
|
|
|
(dvoid*) &parmp2,
|
|
|
|
|
(ub4 *) 0,
|
|
|
|
|
(ub4) OCI_ATTR_COLLECTION_ELEMENT,
|
|
|
|
|
connection->err
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
2005-12-01 21:39:48 +08:00
|
|
|
|
goto CLEANUP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* get REF of the TDO for the type */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
(dvoid*) parmp2,
|
|
|
|
|
(ub4) OCI_DTYPE_PARAM,
|
|
|
|
|
(dvoid*) &(collection->elem_ref),
|
|
|
|
|
(ub4 *) 0,
|
|
|
|
|
(ub4) OCI_ATTR_REF_TDO,
|
|
|
|
|
connection->err
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
2005-12-01 21:39:48 +08:00
|
|
|
|
goto CLEANUP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* get the TDO (only header) */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCITypeByRef,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
connection->env,
|
|
|
|
|
connection->err,
|
|
|
|
|
collection->elem_ref,
|
|
|
|
|
OCI_DURATION_SESSION,
|
|
|
|
|
OCI_TYPEGET_HEADER,
|
|
|
|
|
&(collection->element_type)
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
2005-12-01 21:39:48 +08:00
|
|
|
|
goto CLEANUP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* get typecode */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
(dvoid*) parmp2,
|
|
|
|
|
(ub4) OCI_DTYPE_PARAM,
|
|
|
|
|
(dvoid*) &(collection->element_typecode),
|
|
|
|
|
(ub4 *) 0,
|
|
|
|
|
(ub4) OCI_ATTR_TYPECODE,
|
|
|
|
|
connection->err
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
2005-12-01 21:39:48 +08:00
|
|
|
|
goto CLEANUP;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
/* we only support VARRAYs and TABLEs */
|
|
|
|
|
default:
|
2006-12-23 22:02:50 +08:00
|
|
|
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unknown collection type %d", collection->coll_typecode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create object to hold return table */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIObjectNew,
|
2005-12-01 21:39:48 +08:00
|
|
|
|
(
|
2008-04-18 08:05:27 +08:00
|
|
|
|
connection->env,
|
|
|
|
|
connection->err,
|
|
|
|
|
connection->svc,
|
|
|
|
|
OCI_TYPECODE_TABLE,
|
|
|
|
|
collection->tdo,
|
|
|
|
|
(dvoid *)0,
|
|
|
|
|
OCI_DURATION_DEFAULT,
|
|
|
|
|
TRUE,
|
2005-12-01 21:39:48 +08:00
|
|
|
|
(dvoid **) &(collection->collection)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
2005-12-01 21:39:48 +08:00
|
|
|
|
goto CLEANUP;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-16 07:24:45 +08:00
|
|
|
|
/* free the describe handle (Bug #44113) */
|
2013-08-27 05:20:58 +08:00
|
|
|
|
PHP_OCI_CALL(OCIHandleFree, ((dvoid *) dschp1, OCI_HTYPE_DESCRIBE));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
PHP_OCI_REGISTER_RESOURCE(collection, le_collection);
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return collection;
|
|
|
|
|
|
|
|
|
|
CLEANUP:
|
|
|
|
|
|
2008-02-16 07:24:45 +08:00
|
|
|
|
if (dschp1) {
|
|
|
|
|
/* free the describe handle (Bug #44113) */
|
2013-08-27 05:20:58 +08:00
|
|
|
|
PHP_OCI_CALL(OCIHandleFree, ((dvoid *) dschp1, OCI_HTYPE_DESCRIBE));
|
2008-02-16 07:24:45 +08:00
|
|
|
|
}
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
php_oci_collection_close(collection TSRMLS_CC);
|
|
|
|
|
return NULL;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
/* {{{ php_oci_collection_size()
|
2005-12-01 21:39:48 +08:00
|
|
|
|
Return size of the collection */
|
|
|
|
|
int php_oci_collection_size(php_oci_collection *collection, sb4 *size TSRMLS_DC)
|
|
|
|
|
{
|
|
|
|
|
php_oci_connection *connection = collection->connection;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCICollSize, (connection->env, connection->err, collection->collection, (sb4 *)size));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 0;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
/* {{{ php_oci_collection_max()
|
2005-12-01 21:39:48 +08:00
|
|
|
|
Return max number of elements in the collection */
|
2014-09-09 19:12:26 +08:00
|
|
|
|
int php_oci_collection_max(php_oci_collection *collection, zend_long *max TSRMLS_DC)
|
2005-12-01 21:39:48 +08:00
|
|
|
|
{
|
|
|
|
|
php_oci_connection *connection = collection->connection;
|
|
|
|
|
|
2013-08-27 05:20:58 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(*max, OCICollMax, (connection->env, collection->collection));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
/* error handling is not necessary here? */
|
|
|
|
|
return 0;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
/* {{{ php_oci_collection_trim()
|
2005-12-01 21:39:48 +08:00
|
|
|
|
Trim collection to the given number of elements */
|
2014-09-09 19:12:26 +08:00
|
|
|
|
int php_oci_collection_trim(php_oci_collection *collection, zend_long trim_size TSRMLS_DC)
|
2005-12-01 21:39:48 +08:00
|
|
|
|
{
|
|
|
|
|
php_oci_connection *connection = collection->connection;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
|
|
|
|
|
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCICollTrim, (connection->env, connection->err, trim_size, collection->collection));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
errstatus = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 0;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
/* {{{ php_oci_collection_append_null()
|
2005-12-01 21:39:48 +08:00
|
|
|
|
Append NULL element to the end of the collection */
|
|
|
|
|
int php_oci_collection_append_null(php_oci_collection *collection TSRMLS_DC)
|
|
|
|
|
{
|
|
|
|
|
OCIInd null_index = OCI_IND_NULL;
|
|
|
|
|
php_oci_connection *connection = collection->connection;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
/* append NULL element */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCICollAppend, (connection->env, connection->err, (dvoid *)0, &null_index, collection->collection));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
errstatus = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 0;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
/* {{{ php_oci_collection_append_date()
|
2005-12-01 21:39:48 +08:00
|
|
|
|
Append DATE element to the end of the collection (use "DD-MON-YY" format) */
|
|
|
|
|
int php_oci_collection_append_date(php_oci_collection *collection, char *date, int date_len TSRMLS_DC)
|
|
|
|
|
{
|
|
|
|
|
OCIInd new_index = OCI_IND_NOTNULL;
|
|
|
|
|
OCIDate oci_date;
|
|
|
|
|
php_oci_connection *connection = collection->connection;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
/* format and language are NULLs, so format is "DD-MON-YY" and language is the default language of the session */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIDateFromText, (connection->err, (CONST text *)date, date_len, NULL, 0, NULL, 0, &oci_date));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
2005-12-01 21:39:48 +08:00
|
|
|
|
/* failed to convert string to date */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCICollAppend,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
connection->env,
|
|
|
|
|
connection->err,
|
|
|
|
|
(dvoid *) &oci_date,
|
|
|
|
|
(dvoid *) &new_index,
|
|
|
|
|
(OCIColl *) collection->collection
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 0;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
/* {{{ php_oci_collection_append_number()
|
|
|
|
|
Append NUMBER to the end of the collection */
|
|
|
|
|
int php_oci_collection_append_number(php_oci_collection *collection, char *number, int number_len TSRMLS_DC)
|
|
|
|
|
{
|
|
|
|
|
OCIInd new_index = OCI_IND_NOTNULL;
|
|
|
|
|
double element_double;
|
|
|
|
|
OCINumber oci_number;
|
|
|
|
|
php_oci_connection *connection = collection->connection;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
element_double = zend_strtod(number, NULL);
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCICollAppend,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
connection->env,
|
|
|
|
|
connection->err,
|
|
|
|
|
(dvoid *) &oci_number,
|
|
|
|
|
(dvoid *) &new_index,
|
|
|
|
|
(OCIColl *) collection->collection
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 0;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
/* {{{ php_oci_collection_append_string()
|
2005-12-01 21:39:48 +08:00
|
|
|
|
Append STRING to the end of the collection */
|
|
|
|
|
int php_oci_collection_append_string(php_oci_collection *collection, char *element, int element_len TSRMLS_DC)
|
|
|
|
|
{
|
|
|
|
|
OCIInd new_index = OCI_IND_NOTNULL;
|
|
|
|
|
OCIString *ocistr = (OCIString *)0;
|
|
|
|
|
php_oci_connection *connection = collection->connection;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIStringAssignText, (connection->env, connection->err, (CONST oratext *)element, element_len, &ocistr));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCICollAppend,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
connection->env,
|
|
|
|
|
connection->err,
|
|
|
|
|
(dvoid *) ocistr,
|
|
|
|
|
(dvoid *) &new_index,
|
|
|
|
|
(OCIColl *) collection->collection
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 0;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
/* {{{ php_oci_collection_append()
|
2005-12-01 21:39:48 +08:00
|
|
|
|
Append wrapper. Appends any supported element to the end of the collection */
|
|
|
|
|
int php_oci_collection_append(php_oci_collection *collection, char *element, int element_len TSRMLS_DC)
|
|
|
|
|
{
|
|
|
|
|
if (element_len == 0) {
|
|
|
|
|
return php_oci_collection_append_null(collection TSRMLS_CC);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch(collection->element_typecode) {
|
|
|
|
|
case OCI_TYPECODE_DATE:
|
|
|
|
|
return php_oci_collection_append_date(collection, element, element_len TSRMLS_CC);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OCI_TYPECODE_VARCHAR2 :
|
|
|
|
|
return php_oci_collection_append_string(collection, element, element_len TSRMLS_CC);
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
case OCI_TYPECODE_UNSIGNED16 : /* UNSIGNED SHORT */
|
|
|
|
|
case OCI_TYPECODE_UNSIGNED32 : /* UNSIGNED LONG */
|
|
|
|
|
case OCI_TYPECODE_REAL : /* REAL */
|
|
|
|
|
case OCI_TYPECODE_DOUBLE : /* DOUBLE */
|
|
|
|
|
case OCI_TYPECODE_INTEGER : /* INT */
|
|
|
|
|
case OCI_TYPECODE_SIGNED16 : /* SHORT */
|
|
|
|
|
case OCI_TYPECODE_SIGNED32 : /* LONG */
|
|
|
|
|
case OCI_TYPECODE_DECIMAL : /* DECIMAL */
|
|
|
|
|
case OCI_TYPECODE_FLOAT : /* FLOAT */
|
|
|
|
|
case OCI_TYPECODE_NUMBER : /* NUMBER */
|
|
|
|
|
case OCI_TYPECODE_SMALLINT : /* SMALLINT */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return php_oci_collection_append_number(collection, element, element_len TSRMLS_CC);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown or unsupported type of element: %d", collection->element_typecode);
|
|
|
|
|
return 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* never reached */
|
|
|
|
|
return 1;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
/* {{{ php_oci_collection_element_get()
|
2005-12-01 21:39:48 +08:00
|
|
|
|
Get the element with the given index */
|
2014-09-10 03:50:26 +08:00
|
|
|
|
int php_oci_collection_element_get(php_oci_collection *collection, zend_long index, zval *result_element TSRMLS_DC)
|
2005-12-01 21:39:48 +08:00
|
|
|
|
{
|
|
|
|
|
php_oci_connection *connection = collection->connection;
|
|
|
|
|
dvoid *element;
|
|
|
|
|
OCIInd *element_index;
|
|
|
|
|
boolean exists;
|
2007-07-18 23:10:42 +08:00
|
|
|
|
oratext buff[1024];
|
|
|
|
|
ub4 buff_len = 1024;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2014-09-10 03:50:26 +08:00
|
|
|
|
ZVAL_NULL(result_element);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
|
|
|
|
|
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCICollGetElem,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
connection->env,
|
|
|
|
|
connection->err,
|
|
|
|
|
collection->collection,
|
|
|
|
|
(ub4)index,
|
|
|
|
|
&exists,
|
|
|
|
|
&element,
|
|
|
|
|
(dvoid **)&element_index
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (exists == 0) {
|
|
|
|
|
/* element doesn't exist */
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*element_index == OCI_IND_NULL) {
|
|
|
|
|
/* this is not an error, we're returning NULL here */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (collection->element_typecode) {
|
|
|
|
|
case OCI_TYPECODE_DATE:
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIDateToText, (connection->err, element, 0, 0, 0, 0, &buff_len, buff));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-10 18:40:32 +08:00
|
|
|
|
ZVAL_STRINGL(result_element, (char *)buff, buff_len);
|
2014-09-10 03:50:26 +08:00
|
|
|
|
Z_STRVAL_P(result_element)[buff_len] = '\0';
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OCI_TYPECODE_VARCHAR2:
|
|
|
|
|
{
|
|
|
|
|
OCIString *oci_string = *(OCIString **)element;
|
|
|
|
|
text *str;
|
|
|
|
|
|
2013-08-27 05:20:58 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(str, OCIStringPtr, (connection->env, oci_string));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
if (str) {
|
2014-09-10 03:50:26 +08:00
|
|
|
|
ZVAL_STRING(result_element, (char *)str);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
case OCI_TYPECODE_UNSIGNED16: /* UNSIGNED SHORT */
|
|
|
|
|
case OCI_TYPECODE_UNSIGNED32: /* UNSIGNED LONG */
|
|
|
|
|
case OCI_TYPECODE_REAL: /* REAL */
|
|
|
|
|
case OCI_TYPECODE_DOUBLE: /* DOUBLE */
|
|
|
|
|
case OCI_TYPECODE_INTEGER: /* INT */
|
|
|
|
|
case OCI_TYPECODE_SIGNED16: /* SHORT */
|
|
|
|
|
case OCI_TYPECODE_SIGNED32: /* LONG */
|
|
|
|
|
case OCI_TYPECODE_DECIMAL: /* DECIMAL */
|
|
|
|
|
case OCI_TYPECODE_FLOAT: /* FLOAT */
|
|
|
|
|
case OCI_TYPECODE_NUMBER: /* NUMBER */
|
|
|
|
|
case OCI_TYPECODE_SMALLINT: /* SMALLINT */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
{
|
|
|
|
|
double double_number;
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCINumberToReal, (connection->err, (CONST OCINumber *) element, (uword) sizeof(double), (dvoid *) &double_number));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-10 03:50:26 +08:00
|
|
|
|
ZVAL_DOUBLE(result_element, double_number);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown or unsupported type of element: %d", collection->element_typecode);
|
|
|
|
|
return 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* never reached */
|
|
|
|
|
return 1;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
/* {{{ php_oci_collection_element_set_null()
|
2005-12-01 21:39:48 +08:00
|
|
|
|
Set the element with the given index to NULL */
|
2014-09-09 19:12:26 +08:00
|
|
|
|
int php_oci_collection_element_set_null(php_oci_collection *collection, zend_long index TSRMLS_DC)
|
2005-12-01 21:39:48 +08:00
|
|
|
|
{
|
|
|
|
|
OCIInd null_index = OCI_IND_NULL;
|
|
|
|
|
php_oci_connection *connection = collection->connection;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
/* set NULL element */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCICollAssignElem, (connection->env, connection->err, (ub4) index, (dvoid *)"", &null_index, collection->collection));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 0;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
/* {{{ php_oci_collection_element_set_date()
|
2005-12-01 21:39:48 +08:00
|
|
|
|
Change element's value to the given DATE */
|
2014-09-09 19:12:26 +08:00
|
|
|
|
int php_oci_collection_element_set_date(php_oci_collection *collection, zend_long index, char *date, int date_len TSRMLS_DC)
|
2005-12-01 21:39:48 +08:00
|
|
|
|
{
|
|
|
|
|
OCIInd new_index = OCI_IND_NOTNULL;
|
|
|
|
|
OCIDate oci_date;
|
|
|
|
|
php_oci_connection *connection = collection->connection;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
/* format and language are NULLs, so format is "DD-MON-YY" and language is the default language of the session */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIDateFromText, (connection->err, (CONST text *)date, date_len, NULL, 0, NULL, 0, &oci_date));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
2005-12-01 21:39:48 +08:00
|
|
|
|
/* failed to convert string to date */
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCICollAssignElem,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
connection->env,
|
|
|
|
|
connection->err,
|
|
|
|
|
(ub4)index,
|
|
|
|
|
(dvoid *) &oci_date,
|
|
|
|
|
(dvoid *) &new_index,
|
|
|
|
|
(OCIColl *) collection->collection
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 0;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
/* {{{ php_oci_collection_element_set_number()
|
|
|
|
|
Change element's value to the given NUMBER */
|
2014-09-09 19:12:26 +08:00
|
|
|
|
int php_oci_collection_element_set_number(php_oci_collection *collection, zend_long index, char *number, int number_len TSRMLS_DC)
|
2005-12-01 21:39:48 +08:00
|
|
|
|
{
|
|
|
|
|
OCIInd new_index = OCI_IND_NOTNULL;
|
|
|
|
|
double element_double;
|
|
|
|
|
OCINumber oci_number;
|
|
|
|
|
php_oci_connection *connection = collection->connection;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
element_double = zend_strtod(number, NULL);
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCICollAssignElem,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
connection->env,
|
|
|
|
|
connection->err,
|
|
|
|
|
(ub4) index,
|
|
|
|
|
(dvoid *) &oci_number,
|
|
|
|
|
(dvoid *) &new_index,
|
|
|
|
|
(OCIColl *) collection->collection
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 0;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
/* {{{ php_oci_collection_element_set_string()
|
|
|
|
|
Change element's value to the given string */
|
2014-09-09 19:12:26 +08:00
|
|
|
|
int php_oci_collection_element_set_string(php_oci_collection *collection, zend_long index, char *element, int element_len TSRMLS_DC)
|
2005-12-01 21:39:48 +08:00
|
|
|
|
{
|
|
|
|
|
OCIInd new_index = OCI_IND_NOTNULL;
|
|
|
|
|
OCIString *ocistr = (OCIString *)0;
|
|
|
|
|
php_oci_connection *connection = collection->connection;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIStringAssignText, (connection->env, connection->err, (CONST oratext *)element, element_len, &ocistr));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCICollAssignElem,
|
2006-08-15 21:08:34 +08:00
|
|
|
|
(
|
|
|
|
|
connection->env,
|
|
|
|
|
connection->err,
|
|
|
|
|
(ub4)index,
|
|
|
|
|
(dvoid *) ocistr,
|
|
|
|
|
(dvoid *) &new_index,
|
|
|
|
|
(OCIColl *) collection->collection
|
|
|
|
|
)
|
|
|
|
|
);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 0;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
/* {{{ php_oci_collection_element_set()
|
|
|
|
|
Collection element setter */
|
2014-09-09 19:12:26 +08:00
|
|
|
|
int php_oci_collection_element_set(php_oci_collection *collection, zend_long index, char *value, int value_len TSRMLS_DC)
|
2005-12-01 21:39:48 +08:00
|
|
|
|
{
|
|
|
|
|
if (value_len == 0) {
|
|
|
|
|
return php_oci_collection_element_set_null(collection, index TSRMLS_CC);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch(collection->element_typecode) {
|
|
|
|
|
case OCI_TYPECODE_DATE:
|
|
|
|
|
return php_oci_collection_element_set_date(collection, index, value, value_len TSRMLS_CC);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OCI_TYPECODE_VARCHAR2 :
|
|
|
|
|
return php_oci_collection_element_set_string(collection, index, value, value_len TSRMLS_CC);
|
|
|
|
|
break;
|
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
case OCI_TYPECODE_UNSIGNED16 : /* UNSIGNED SHORT */
|
|
|
|
|
case OCI_TYPECODE_UNSIGNED32 : /* UNSIGNED LONG */
|
|
|
|
|
case OCI_TYPECODE_REAL : /* REAL */
|
|
|
|
|
case OCI_TYPECODE_DOUBLE : /* DOUBLE */
|
|
|
|
|
case OCI_TYPECODE_INTEGER : /* INT */
|
|
|
|
|
case OCI_TYPECODE_SIGNED16 : /* SHORT */
|
|
|
|
|
case OCI_TYPECODE_SIGNED32 : /* LONG */
|
|
|
|
|
case OCI_TYPECODE_DECIMAL : /* DECIMAL */
|
|
|
|
|
case OCI_TYPECODE_FLOAT : /* FLOAT */
|
|
|
|
|
case OCI_TYPECODE_NUMBER : /* NUMBER */
|
|
|
|
|
case OCI_TYPECODE_SMALLINT : /* SMALLINT */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return php_oci_collection_element_set_number(collection, index, value, value_len TSRMLS_CC);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown or unsupported type of element: %d", collection->element_typecode);
|
|
|
|
|
return 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* never reached */
|
|
|
|
|
return 1;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2008-04-18 08:05:27 +08:00
|
|
|
|
/* {{{ php_oci_collection_assign()
|
2005-12-01 21:39:48 +08:00
|
|
|
|
Assigns a value to the collection from another collection */
|
|
|
|
|
int php_oci_collection_assign(php_oci_collection *collection_dest, php_oci_collection *collection_from TSRMLS_DC)
|
|
|
|
|
{
|
|
|
|
|
php_oci_connection *connection = collection_dest->connection;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCICollAssign, (connection->env, connection->err, collection_from->collection, collection_dest->collection));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
2013-09-06 09:18:29 +08:00
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
return 0;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
/* {{{ php_oci_collection_close()
|
|
|
|
|
Destroy collection and all associated resources */
|
|
|
|
|
void php_oci_collection_close(php_oci_collection *collection TSRMLS_DC)
|
|
|
|
|
{
|
|
|
|
|
php_oci_connection *connection = collection->connection;
|
2013-09-06 09:18:29 +08:00
|
|
|
|
sword errstatus;
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
if (collection->collection) {
|
2013-09-06 09:18:29 +08:00
|
|
|
|
PHP_OCI_CALL_RETURN(errstatus, OCIObjectFree, (connection->env, connection->err, (dvoid *)collection->collection, (ub2)OCI_OBJECTFREE_FORCE));
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
2013-09-06 09:18:29 +08:00
|
|
|
|
if (errstatus != OCI_SUCCESS) {
|
|
|
|
|
connection->errcode = php_oci_error(connection->err, errstatus TSRMLS_CC);
|
2008-03-22 09:27:50 +08:00
|
|
|
|
PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
|
2013-09-06 09:18:29 +08:00
|
|
|
|
} else {
|
|
|
|
|
connection->errcode = 0; /* retain backwards compat with OCI8 1.4 */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 06:33:22 +08:00
|
|
|
|
zend_list_delete(collection->connection->id);
|
2005-12-01 21:39:48 +08:00
|
|
|
|
efree(collection);
|
|
|
|
|
return;
|
2013-07-25 06:33:22 +08:00
|
|
|
|
}
|
|
|
|
|
/* }}} */
|
2005-12-01 21:39:48 +08:00
|
|
|
|
|
|
|
|
|
#endif /* HAVE_OCI8 */
|
2007-08-01 03:21:08 +08:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Local variables:
|
|
|
|
|
* tab-width: 4
|
|
|
|
|
* c-basic-offset: 4
|
|
|
|
|
* End:
|
|
|
|
|
* vim600: noet sw=4 ts=4 fdm=marker
|
|
|
|
|
* vim<600: noet sw=4 ts=4
|
|
|
|
|
*/
|