@@ -523,12 +523,12 @@ PHP_FUNCTION(mysqli_execute_query)
523
523
524
524
if (FAIL == mysql_stmt_prepare (stmt -> stmt , query , query_len )) {
525
525
MYSQLI_REPORT_STMT_ERROR (stmt -> stmt );
526
-
526
+
527
527
close_stmt_and_copy_errors (stmt , mysql );
528
528
RETURN_FALSE ;
529
529
}
530
530
531
- /* The bit below, which is copied from mysqli_prepare, is needed for bad index exceptions */
531
+ /* The bit below, which is copied from mysqli_prepare, is needed for bad index exceptions */
532
532
/* don't initialize stmt->query with NULL, we ecalloc()-ed the memory */
533
533
/* Get performance boost if reporting is switched off */
534
534
if (query_len && (MyG (report_mode ) & MYSQLI_REPORT_INDEX )) {
@@ -647,28 +647,118 @@ PHP_FUNCTION(mysqli_stmt_fetch)
647
647
/* }}} */
648
648
649
649
/* {{{ php_add_field_properties */
650
- static void php_add_field_properties (zval * value , const MYSQL_FIELD * field )
651
- {
652
- add_property_str (value , "name" , zend_string_copy (field -> sname ));
653
-
654
- add_property_stringl (value , "orgname" , (field -> org_name ? field -> org_name : "" ), field -> org_name_length );
655
- add_property_stringl (value , "table" , (field -> table ? field -> table : "" ), field -> table_length );
656
- add_property_stringl (value , "orgtable" , (field -> org_table ? field -> org_table : "" ), field -> org_table_length );
657
- add_property_stringl (value , "def" , (field -> def ? field -> def : "" ), field -> def_length );
658
- add_property_stringl (value , "db" , (field -> db ? field -> db : "" ), field -> db_length );
650
+ static void php_add_field_properties (zval * z_object , const MYSQL_FIELD * field )
651
+ {
652
+ zend_update_property_str_ex (
653
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
654
+ ZSTR_KNOWN (ZEND_STR_NAME ), field -> sname
655
+ );
656
+ if (field -> org_name ) {
657
+ zend_update_property_stringl (
658
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
659
+ "orgname" , strlen ("orgname" ),
660
+ field -> org_name , field -> org_name_length
661
+ );
662
+ } else {
663
+ zend_update_property_str (
664
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
665
+ "orgname" , strlen ("orgname" ),
666
+ zend_empty_string
667
+ );
668
+ }
669
+ if (field -> table ) {
670
+ zend_update_property_stringl (
671
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
672
+ "table" , strlen ("table" ),
673
+ field -> table , field -> table_length
674
+ );
675
+ } else {
676
+ zend_update_property_str (
677
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
678
+ "table" , strlen ("table" ),
679
+ zend_empty_string
680
+ );
681
+ }
682
+ if (field -> org_table ) {
683
+ zend_update_property_stringl (
684
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
685
+ "orgtable" , strlen ("orgtable" ),
686
+ field -> org_table , field -> org_table_length
687
+ );
688
+ } else {
689
+ zend_update_property_str (
690
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
691
+ "orgtable" , strlen ("orgtable" ),
692
+ zend_empty_string
693
+ );
694
+ }
695
+ if (field -> def ) {
696
+ zend_update_property_stringl (
697
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
698
+ "def" , strlen ("def" ),
699
+ field -> def , field -> def_length
700
+ );
701
+ } else {
702
+ zend_update_property_str (
703
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
704
+ "def" , strlen ("def" ),
705
+ zend_empty_string
706
+ );
707
+ }
708
+ if (field -> db ) {
709
+ zend_update_property_stringl (
710
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
711
+ "db" , strlen ("db" ),
712
+ field -> db , field -> db_length
713
+ );
714
+ } else {
715
+ zend_update_property_str (
716
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
717
+ "db" , strlen ("db" ),
718
+ zend_empty_string
719
+ );
720
+ }
659
721
660
722
/* FIXME: manually set the catalog to "def" due to bug in
661
723
* libmysqlclient which does not initialize field->catalog
662
724
* and in addition, the catalog is always be "def"
663
725
*/
664
- add_property_string (value , "catalog" , "def" );
665
-
666
- add_property_long (value , "max_length" , 0 );
667
- add_property_long (value , "length" , field -> length );
668
- add_property_long (value , "charsetnr" , field -> charsetnr );
669
- add_property_long (value , "flags" , field -> flags );
670
- add_property_long (value , "type" , field -> type );
671
- add_property_long (value , "decimals" , field -> decimals );
726
+ zend_update_property_stringl (
727
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
728
+ "catalog" , strlen ("catalog" ),
729
+ "def" , strlen ("def" )
730
+ );
731
+
732
+ zend_update_property_long (
733
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
734
+ "max_length" , strlen ("max_length" ),
735
+ 0
736
+ );
737
+ zend_update_property_long (
738
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
739
+ "length" , strlen ("length" ),
740
+ field -> length
741
+ );
742
+ zend_update_property_long (
743
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
744
+ "charsetnr" , strlen ("charsetnr" ),
745
+ field -> charsetnr
746
+ );
747
+ zend_update_property_long (
748
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
749
+ "flags" , strlen ("flags" ),
750
+ field -> flags
751
+ );
752
+ zend_update_property_long_ex (
753
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
754
+ ZSTR_KNOWN (ZEND_STR_TYPE ),
755
+ field -> type
756
+ );
757
+ zend_update_property_long (
758
+ Z_OBJCE_P (z_object ), Z_OBJ_P (z_object ),
759
+ "decimals" , strlen ("decimals" ),
760
+ field -> decimals
761
+ );
672
762
}
673
763
/* }}} */
674
764
0 commit comments