stmt->default_fetch_type = dbh->default_fetch_type;
stmt->dbh = dbh;
/* give it a reference to me */
- Z_ADDREF_P(getThis());
- php_pdo_dbh_addref(dbh TSRMLS_CC);
- ZVAL_COPY_VALUE(&stmt->database_object_handle, getThis());
+ ZVAL_OBJ(&stmt->database_object_handle, &dbh->std);
+ Z_ADDREF(stmt->database_object_handle);
/* we haven't created a lazy object yet */
ZVAL_UNDEF(&stmt->lazy_object_ref);
stmt->active_query_stringlen = statement_len;
stmt->dbh = dbh;
/* give it a reference to me */
- Z_ADDREF_P(getThis());
- php_pdo_dbh_addref(dbh TSRMLS_CC);
- stmt->database_object_handle = *getThis();
+ ZVAL_OBJ(&stmt->database_object_handle, &dbh->std);
+ Z_ADDREF(stmt->database_object_handle);
/* we haven't created a lazy object yet */
ZVAL_UNDEF(&stmt->lazy_object_ref);
PDO_HANDLE_STMT_ERR();
} else {
PDO_HANDLE_DBH_ERR();
- zval_dtor(return_value);
+ zval_ptr_dtor(return_value);
}
RETURN_FALSE;
{
int i;
- if (--dbh->refcount)
- return;
-
if (dbh->query_stmt) {
- zval_dtor(&dbh->query_stmt_zval);
+ zval_ptr_dtor(&dbh->query_stmt_zval);
dbh->query_stmt = NULL;
}
//???pefree(dbh, dbh->is_persistent);
}
-PDO_API void php_pdo_dbh_addref(pdo_dbh_t *dbh TSRMLS_DC)
-{
- dbh->refcount++;
-}
-
-PDO_API void php_pdo_dbh_delref(pdo_dbh_t *dbh TSRMLS_DC)
-{
- dbh_free(dbh TSRMLS_CC);
-}
-
static void pdo_dbh_free_storage(zend_object *std TSRMLS_DC)
{
pdo_dbh_t *dbh = php_pdo_dbh_fetch_object(std);
zend_objects_clone_members(&stmt->std, &old_stmt->std TSRMLS_CC);
- ZVAL_COPY(&stmt->database_object_handle, &old_stmt->database_object_handle);
-
return &stmt->std;
}
do_fetch_opt_finish(stmt, 1 TSRMLS_CC);
- zval_ptr_dtor(&stmt->database_object_handle);
- if (stmt->dbh) {
- php_pdo_dbh_delref(stmt->dbh TSRMLS_CC);
+ if (!ZVAL_IS_UNDEF(&stmt->database_object_handle)) {
+ zval_ptr_dtor(&stmt->database_object_handle);
}
zend_object_std_dtor(&stmt->std TSRMLS_CC);
}