42
42
#error Use PHP OCI8 1.4 for your version of PHP
43
43
#endif
44
44
45
+ /* PHP 7 is the minimum supported version for OCI8 2.1 */
46
+ #if PHP_MAJOR_VERSION < 7
47
+ #error Use PHP OCI8 2.0 for your version of PHP
48
+ #endif
49
+
45
50
#include "php_oci8.h"
46
51
#include "php_oci8_int.h"
47
52
#include "zend_hash.h"
@@ -2629,6 +2634,8 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode)
2629
2634
void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS , int mode , int expected_args )
2630
2635
{
2631
2636
zval * z_statement , * array ;
2637
+ zval * placeholder ;
2638
+ /* zend_array *temp_array = (zend_array *) NULL;*/
2632
2639
php_oci_statement * statement ; /* statement that will be fetched from */
2633
2640
#if (OCI_MAJOR_VERSION >= 12 )
2634
2641
php_oci_statement * invokedstatement ; /* statement this function was invoked with */
@@ -2736,53 +2743,16 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg
2736
2743
}
2737
2744
#endif /* OCI_MAJOR_VERSION */
2738
2745
2739
- #if 0
2740
- if (expected_args > 2 )
2741
- {
2742
- array_init (array );
2743
-
2744
- for (i = 0 ; i < statement -> ncolumns ; i ++ ) {
2745
-
2746
- column = php_oci_statement_get_column (statement , i + 1 , NULL , 0 );
2747
-
2748
- if (column == NULL ) {
2749
- continue ;
2750
- }
2751
- if ((column -> indicator == -1 ) && ((fetch_mode & PHP_OCI_RETURN_NULLS ) == 0 )) {
2752
- continue ;
2753
- }
2754
-
2755
- if (!(column -> indicator == -1 )) {
2756
- zval element ;
2757
-
2758
- php_oci_column_to_zval (column , & element , fetch_mode );
2759
-
2760
- if (fetch_mode & PHP_OCI_NUM || !(fetch_mode & PHP_OCI_ASSOC )) {
2761
- add_index_zval (array , i , & element );
2762
- }
2763
- if (fetch_mode & PHP_OCI_ASSOC ) {
2764
- if (fetch_mode & PHP_OCI_NUM ) {
2765
- Z_TRY_ADDREF_P (& element );
2766
- }
2767
- add_assoc_zval (array , column -> name , & element );
2768
- }
2769
-
2770
- } else {
2771
- if (fetch_mode & PHP_OCI_NUM || !(fetch_mode & PHP_OCI_ASSOC )) {
2772
- add_index_null (array , i );
2773
- }
2774
- if (fetch_mode & PHP_OCI_ASSOC ) {
2775
- add_assoc_null (array , column -> name );
2776
- }
2777
- }
2778
- }
2779
-
2780
- /* RETURN_LONG(statement->ncolumns); */
2746
+ if (expected_args > 2 ) {
2747
+ if (Z_ISREF_P (array ))
2748
+ placeholder = Z_REFVAL_P (array );
2749
+ else
2750
+ placeholder = array ;
2751
+ } else {
2752
+ placeholder = return_value ;
2781
2753
}
2782
- else
2783
- #endif
2784
- {
2785
- array_init (return_value );
2754
+
2755
+ array_init (placeholder );
2786
2756
2787
2757
for (i = 0 ; i < statement -> ncolumns ; i ++ ) {
2788
2758
@@ -2801,32 +2771,42 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg
2801
2771
php_oci_column_to_zval (column , & element , (int ) fetch_mode );
2802
2772
2803
2773
if (fetch_mode & PHP_OCI_NUM || !(fetch_mode & PHP_OCI_ASSOC )) {
2804
- add_index_zval (return_value , i , & element );
2774
+ add_index_zval (placeholder , i , & element );
2805
2775
}
2806
2776
if (fetch_mode & PHP_OCI_ASSOC ) {
2807
2777
if (fetch_mode & PHP_OCI_NUM ) {
2808
2778
Z_TRY_ADDREF_P (& element );
2809
2779
}
2810
- add_assoc_zval (return_value , column -> name , & element );
2780
+ add_assoc_zval (placeholder , column -> name , & element );
2811
2781
}
2812
2782
2813
2783
} else {
2814
2784
if (fetch_mode & PHP_OCI_NUM || !(fetch_mode & PHP_OCI_ASSOC )) {
2815
- add_index_null (return_value , i );
2785
+ add_index_null (placeholder , i );
2816
2786
}
2817
2787
if (fetch_mode & PHP_OCI_ASSOC ) {
2818
- add_assoc_null (return_value , column -> name );
2788
+ add_assoc_null (placeholder , column -> name );
2819
2789
}
2820
2790
}
2821
2791
}
2822
2792
2823
2793
if (expected_args > 2 ) {
2824
2794
/* Only for ocifetchinto BC. In all other cases we return array, not long */
2825
- ZVAL_COPY (array , return_value ); /* copy return_value to given reference */
2826
- /* zval_dtor(return_value); */
2795
+ #if 0
2796
+ zval * temp_array ;
2797
+ if (Z_ISREF_P (array ))
2798
+ temp_array = Z_REFVAL_P (array );
2799
+ else /* PHP7 will pass user buffer through 'array' as reference type.
2800
+ * So this part of code may not be reached. */
2801
+ temp_array = array ;
2802
+
2803
+ /* copy array content in return_value into user buffer passed through
2804
+ * reference variable 'array' */
2805
+ ZVAL_ARR (temp_array , Z_ARRVAL_P (return_value ));
2806
+ zval_ptr_dtor (return_value );
2807
+ #endif
2827
2808
RETURN_LONG (statement -> ncolumns );
2828
2809
}
2829
- }
2830
2810
}
2831
2811
/* }}} */
2832
2812
0 commit comments