44
44
45
45
PHONGO_API zend_class_entry * php_phongo_writeresult_ce ;
46
46
47
+ zend_object_handlers php_phongo_handler_writeresult ;
48
+
47
49
/* {{{ proto integer WriteResult::getInsertedCount()
48
50
Returns the number of documents that were inserted */
49
51
PHP_METHOD (WriteResult , getInsertedCount )
@@ -369,17 +371,62 @@ zend_object_value php_phongo_writeresult_create_object(zend_class_entry *class_t
369
371
zend_object_value retval ;
370
372
php_phongo_writeresult_t * intern = NULL ;
371
373
372
- intern = (php_phongo_writeresult_t * )emalloc (sizeof (php_phongo_writeresult_t ));
373
- memset (intern , 0 , sizeof (php_phongo_writeresult_t ));
374
+ intern = (php_phongo_writeresult_t * )ecalloc (1 , sizeof * intern );
374
375
375
376
zend_object_std_init (& intern -> result .std , class_type TSRMLS_CC );
376
377
object_properties_init (& intern -> result .std , class_type );
377
378
378
379
retval .handle = zend_objects_store_put (intern , (zend_objects_store_dtor_t ) zend_objects_destroy_object , php_phongo_writeresult_free_object , NULL TSRMLS_CC );
379
- retval .handlers = phongo_get_std_object_handlers () ;
380
+ retval .handlers = & php_phongo_handler_writeresult ;
380
381
381
382
return retval ;
382
383
} /* }}} */
384
+
385
+ HashTable * php_phongo_writeresult_get_debug_info (zval * object , int * is_temp TSRMLS_DC ) /* {{{ */
386
+ {
387
+ php_phongo_writeresult_t * intern ;
388
+ zval retval = zval_used_for_init ;
389
+
390
+ intern = (php_phongo_writeresult_t * )zend_object_store_get_object (object TSRMLS_CC );
391
+ * is_temp = 1 ;
392
+ array_init_size (& retval , 9 );
393
+
394
+ add_assoc_long_ex (& retval , ZEND_STRS ("nInserted" ), intern -> nInserted );
395
+ add_assoc_long_ex (& retval , ZEND_STRS ("nMatched" ), intern -> nMatched );
396
+ add_assoc_long_ex (& retval , ZEND_STRS ("nModified" ), intern -> nModified );
397
+ add_assoc_long_ex (& retval , ZEND_STRS ("nRemoved" ), intern -> nRemoved );
398
+ add_assoc_long_ex (& retval , ZEND_STRS ("nUpserted" ), intern -> nUpserted );
399
+
400
+ if (intern -> info ) {
401
+ zval_add_ref (& intern -> info );
402
+ add_assoc_zval_ex (& retval , ZEND_STRS ("info" ), intern -> info );
403
+ } else {
404
+ add_assoc_null_ex (& retval , ZEND_STRS ("info" ));
405
+ }
406
+
407
+ if (intern -> upsertedIds ) {
408
+ zval_add_ref (& intern -> upsertedIds );
409
+ add_assoc_zval_ex (& retval , ZEND_STRS ("upsertedIds" ), intern -> upsertedIds );
410
+ } else {
411
+ add_assoc_null_ex (& retval , ZEND_STRS ("upsertedIds" ));
412
+ }
413
+
414
+ if (intern -> writeErrors ) {
415
+ zval_add_ref (& intern -> writeErrors );
416
+ add_assoc_zval_ex (& retval , ZEND_STRS ("writeErrors" ), intern -> writeErrors );
417
+ } else {
418
+ add_assoc_null_ex (& retval , ZEND_STRS ("writeErrors" ));
419
+ }
420
+
421
+ if (intern -> writeConcernError ) {
422
+ zval_add_ref (& intern -> writeConcernError );
423
+ add_assoc_zval_ex (& retval , ZEND_STRS ("writeConcernError" ), intern -> writeConcernError );
424
+ } else {
425
+ add_assoc_null_ex (& retval , ZEND_STRS ("writeConcernError" ));
426
+ }
427
+
428
+ return Z_ARRVAL (retval );
429
+ } /* }}} */
383
430
/* }}} */
384
431
385
432
/* {{{ PHP_MINIT_FUNCTION */
@@ -390,10 +437,12 @@ PHP_MINIT_FUNCTION(WriteResult)
390
437
zend_class_entry ce ;
391
438
392
439
INIT_NS_CLASS_ENTRY (ce , "MongoDB\\Driver" , "WriteResult" , php_phongo_writeresult_me );
393
- ce .create_object = php_phongo_writeresult_create_object ;
394
440
php_phongo_writeresult_ce = zend_register_internal_class (& ce TSRMLS_CC );
441
+ php_phongo_writeresult_ce -> create_object = php_phongo_writeresult_create_object ;
395
442
php_phongo_writeresult_ce -> ce_flags |= ZEND_ACC_FINAL_CLASS ;
396
443
444
+ memcpy (& php_phongo_handler_writeresult , phongo_get_std_object_handlers (), sizeof (zend_object_handlers ));
445
+ php_phongo_handler_writeresult .get_debug_info = php_phongo_writeresult_get_debug_info ;
397
446
398
447
return SUCCESS ;
399
448
}
0 commit comments