fix pqcur minit and mshutdown
[m6w6/ext-pq] / src / php_pqstm.c
index 4b71038a63f10167c2266b5d2fb966f834c75707..f3136d9f62cd8b577e7badf4636b734b366eb45f 100644 (file)
@@ -112,7 +112,7 @@ static void php_pqstm_object_read_connection(zval *object, void *o, zval *return
 
 
 ZEND_BEGIN_ARG_INFO_EX(ai_pqstm_construct, 0, 0, 3)
-       ZEND_ARG_OBJ_INFO(0, Connection, pq\\Connection, 0)
+       ZEND_ARG_OBJ_INFO(0, connection, pq\\Connection, 0)
        ZEND_ARG_INFO(0, name)
        ZEND_ARG_INFO(0, query)
        ZEND_ARG_ARRAY_INFO(0, types, 1)
@@ -134,7 +134,9 @@ static PHP_METHOD(pqstm, __construct) {
                php_pqstm_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
                php_pqconn_object_t *conn_obj = zend_object_store_get_object(zconn TSRMLS_CC);
 
-               if (!conn_obj->intern) {
+               if (obj->intern) {
+                       throw_exce(EX_BAD_METHODCALL TSRMLS_CC, "pq\\Statement already initialized");
+               } else if (!conn_obj->intern) {
                        throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Connection not initialized");
                } else {
                        php_pq_params_t *params = php_pq_params_init(&conn_obj->intern->converters, ztypes ? Z_ARRVAL_P(ztypes) : NULL, NULL TSRMLS_CC);
@@ -164,12 +166,12 @@ ZEND_BEGIN_ARG_INFO_EX(ai_pqstm_bind, 0, 0, 2)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(pqstm, bind) {
        long param_no;
-       zval *param_ref;
+       zval **param_ref;
        zend_error_handling zeh;
        STATUS rv;
 
        zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
-       rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz", &param_no, &param_ref);
+       rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lZ", &param_no, &param_ref);
        zend_restore_error_handling(&zeh TSRMLS_CC);
 
        if (SUCCESS == rv) {
@@ -178,8 +180,9 @@ static PHP_METHOD(pqstm, bind) {
                if (!obj->intern) {
                        throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Statement not initialized");
                } else {
-                       Z_ADDREF_P(param_ref);
-                       zend_hash_index_update(&obj->intern->bound, param_no, (void *) &param_ref, sizeof(zval *), NULL);
+                       SEPARATE_ZVAL_TO_MAKE_IS_REF(param_ref);
+                       Z_ADDREF_PP(param_ref);
+                       zend_hash_index_update(&obj->intern->bound, param_no, (void *) param_ref, sizeof(zval *), NULL);
                        zend_hash_sort(&obj->intern->bound, zend_qsort, compare_index, 0 TSRMLS_CC);
                }
        }