} \
} while(0)
-static php_stream *oci_create_lob_stream(pdo_stmt_t *stmt, OCILobLocator *lob);
+static php_stream *oci_create_lob_stream(zval *dbh, pdo_stmt_t *stmt, OCILobLocator *lob);
static int oci_stmt_dtor(pdo_stmt_t *stmt) /* {{{ */
{
* wanted to bind a lob locator into it from the query
* */
- stm = oci_create_lob_stream(stmt, (OCILobLocator*)P->thing);
+ stm = oci_create_lob_stream(&stmt->database_object_handle, stmt, (OCILobLocator*)P->thing);
if (stm) {
OCILobOpen(S->H->svc, S->err, (OCILobLocator*)P->thing, OCI_LOB_READWRITE);
php_stream_to_zval(stm, parameter);
typedef struct _oci_lob_env oci_lob_env;
struct oci_lob_self {
+ zval dbh;
pdo_stmt_t *stmt;
pdo_oci_stmt *S;
OCILobLocator *lob;
static int oci_blob_close(php_stream *stream, int close_handle)
{
struct oci_lob_self *self = (struct oci_lob_self *)stream->abstract;
- /* pdo_stmt_t *stmt = self->stmt; */
+ pdo_stmt_t *stmt = self->stmt;
if (close_handle) {
+ zend_object *obj = &stmt->std;
+
OCILobClose(self->E->svc, self->E->err, self->lob);
+ zval_ptr_dtor(&self->dbh);
+ GC_REFCOUNT(obj)--;
efree(self->E);
efree(self);
}
NULL
};
-static php_stream *oci_create_lob_stream(pdo_stmt_t *stmt, OCILobLocator *lob)
+static php_stream *oci_create_lob_stream(zval *dbh, pdo_stmt_t *stmt, OCILobLocator *lob)
{
php_stream *stm;
struct oci_lob_self *self = ecalloc(1, sizeof(*self));
+
+ ZVAL_COPY_VALUE(&self->dbh, dbh);
self->lob = lob;
self->offset = 1; /* 1-based */
self->stmt = stmt;
stm = php_stream_alloc(&oci_blob_stream_ops, self, 0, "r+b");
if (stm) {
+ zend_object *obj;
+ obj = &stmt->std;
+ Z_ADDREF(self->dbh);
+ GC_REFCOUNT(obj)++;
return stm;
}
if (C->dtype == SQLT_BLOB || C->dtype == SQLT_CLOB) {
if (C->data) {
- *ptr = (char*)oci_create_lob_stream(stmt, (OCILobLocator*)C->data);
+ *ptr = (char*)oci_create_lob_stream(&stmt->database_object_handle, stmt, (OCILobLocator*)C->data);
OCILobOpen(S->H->svc, S->err, (OCILobLocator*)C->data, OCI_LOB_READONLY);
}
*len = (size_t) 0;