X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-pq;a=blobdiff_plain;f=src%2Fphp_pqstm.c;h=a5caa1bd5f5bff865cfe2faaadd40f21694f7726;hp=fbab27e81037f9fe4d0f344b1669493da6086fb3;hb=8897b5a581a86279a2ee371784b6b7670c8b8cc1;hpb=8d0dbf7286d9132be18de64625837afa55409f84 diff --git a/src/php_pqstm.c b/src/php_pqstm.c index fbab27e..a5caa1b 100644 --- a/src/php_pqstm.c +++ b/src/php_pqstm.c @@ -52,7 +52,7 @@ static void php_pqstm_deallocate(php_pqstm_object_t *obj, zend_bool async, zend_ PGresult *res; if ((res = php_pq_exec(obj->intern->conn->intern->conn, smart_str_v(&cmd)))) { - php_pq_clear_res(res); + php_pqres_clear(res); } else if (!silent) { throw_exce(EX_RUNTIME, "Failed to deallocate statement (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn)); } @@ -63,6 +63,7 @@ static void php_pqstm_deallocate(php_pqstm_object_t *obj, zend_bool async, zend_ } obj->intern->allocated = 0; + zend_hash_str_del(&obj->intern->conn->intern->statements, obj->intern->name, strlen(obj->intern->name)); } } @@ -155,6 +156,8 @@ php_pqstm_t *php_pqstm_init(php_pqconn_object_t *conn, const char *name, const c ZEND_INIT_SYMTABLE(&stm->bound); + zend_hash_str_add_ptr(&conn->intern->statements, name, strlen(name), stm); + return stm; } @@ -340,7 +343,7 @@ static PHP_METHOD(pqstm, desc) { add_next_index_long(return_value, PQparamtype(res, p)); } } - php_pq_clear_res(res); + php_pqres_clear(res); php_pqconn_notify_listeners(obj->intern->conn); } } @@ -410,7 +413,7 @@ static PHP_METHOD(pqstm, deallocateAsync) php_pqstm_deallocate_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); } -static zend_always_inline void php_pqstm_prepare_handler(INTERNAL_FUNCTION_PARAMETERS, zend_bool async) +static inline void php_pqstm_prepare_handler(INTERNAL_FUNCTION_PARAMETERS, zend_bool async) { zend_error_handling zeh; ZEND_RESULT_CODE rv; @@ -433,6 +436,9 @@ static zend_always_inline void php_pqstm_prepare_handler(INTERNAL_FUNCTION_PARAM if (SUCCESS == rv) { obj->intern->allocated = 1; + + zend_hash_str_add_ptr(&obj->intern->conn->intern->statements, + obj->intern->name, strlen(obj->intern->name), obj->intern); } } } @@ -453,7 +459,7 @@ static PHP_METHOD(pqstm, prepareAsync) } static zend_function_entry php_pqstm_methods[] = { - PHP_ME(pqstm, __construct, ai_pqstm_construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) + PHP_ME(pqstm, __construct, ai_pqstm_construct, ZEND_ACC_PUBLIC) PHP_ME(pqstm, bind, ai_pqstm_bind, ZEND_ACC_PUBLIC) PHP_ME(pqstm, deallocate, ai_pqstm_deallocate, ZEND_ACC_PUBLIC) PHP_ME(pqstm, deallocateAsync, ai_pqstm_deallocate_async, ZEND_ACC_PUBLIC)