@@ -2060,6 +2060,34 @@ static int dbstmt_compare(zval *object1, zval *object2 TSRMLS_DC)
20602060 return -1 ;
20612061}
20622062
2063+ static zend_object_value dbstmt_clone_obj (zval * zobject TSRMLS_DC )
2064+ {
2065+ zend_object_value retval ;
2066+ zval * tmp ;
2067+ pdo_stmt_t * stmt ;
2068+ pdo_stmt_t * old_stmt ;
2069+ zend_object_handle handle = Z_OBJ_HANDLE_P (zobject );
2070+
2071+ stmt = ecalloc (1 , sizeof (* stmt ));
2072+ stmt -> ce = Z_OBJCE_P (zobject );
2073+ stmt -> refcount = 1 ;
2074+ ALLOC_HASHTABLE (stmt -> properties );
2075+ zend_hash_init (stmt -> properties , 0 , NULL , ZVAL_PTR_DTOR , 0 );
2076+ zend_hash_copy (stmt -> properties , & stmt -> ce -> default_properties , (copy_ctor_func_t ) zval_add_ref , (void * ) & tmp , sizeof (zval * ));
2077+
2078+ old_stmt = (pdo_stmt_t * )zend_object_store_get_object (zobject TSRMLS_CC );
2079+
2080+ retval .handle = zend_objects_store_put (stmt , (zend_objects_store_dtor_t )zend_objects_destroy_object , (zend_objects_free_object_storage_t )pdo_dbstmt_free_storage , (zend_objects_store_clone_t )dbstmt_clone_obj TSRMLS_CC );
2081+ retval .handlers = Z_OBJ_HT_P (zobject );
2082+
2083+ zend_objects_clone_members ((zend_object * )stmt , retval , (zend_object * )old_stmt , handle TSRMLS_CC );
2084+
2085+ zend_objects_store_add_ref (& old_stmt -> database_object_handle TSRMLS_CC );
2086+ stmt -> database_object_handle = old_stmt -> database_object_handle ;
2087+
2088+ return retval ;
2089+ }
2090+
20632091zend_object_handlers pdo_dbstmt_object_handlers ;
20642092
20652093void pdo_stmt_init (TSRMLS_D )
@@ -2078,6 +2106,7 @@ void pdo_stmt_init(TSRMLS_D)
20782106 pdo_dbstmt_object_handlers .unset_property = dbstmt_prop_delete ;
20792107 pdo_dbstmt_object_handlers .get_method = dbstmt_method_get ;
20802108 pdo_dbstmt_object_handlers .compare_objects = dbstmt_compare ;
2109+ pdo_dbstmt_object_handlers .clone_obj = dbstmt_clone_obj ;
20812110
20822111 INIT_CLASS_ENTRY (ce , "PDORow" , pdo_row_functions );
20832112 pdo_row_ce = zend_register_internal_class (& ce TSRMLS_CC );
@@ -2172,7 +2201,7 @@ zend_object_value pdo_dbstmt_new(zend_class_entry *ce TSRMLS_DC)
21722201 zend_hash_init (stmt -> properties , 0 , NULL , ZVAL_PTR_DTOR , 0 );
21732202 zend_hash_copy (stmt -> properties , & ce -> default_properties , (copy_ctor_func_t ) zval_add_ref , (void * ) & tmp , sizeof (zval * ));
21742203
2175- retval .handle = zend_objects_store_put (stmt , (zend_objects_store_dtor_t )zend_objects_destroy_object , (zend_objects_free_object_storage_t )pdo_dbstmt_free_storage , NULL TSRMLS_CC );
2204+ retval .handle = zend_objects_store_put (stmt , (zend_objects_store_dtor_t )zend_objects_destroy_object , (zend_objects_free_object_storage_t )pdo_dbstmt_free_storage , ( zend_objects_store_clone_t ) dbstmt_clone_obj TSRMLS_CC );
21762205 retval .handlers = & pdo_dbstmt_object_handlers ;
21772206
21782207 return retval ;
0 commit comments