From 753359f19c5d29f08faca43ee735c49c217230a7 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Thu, 25 Sep 2014 14:04:35 +0200 Subject: [PATCH] update from docs --- gen_pg_type.sh => gen_pq_type.sh | 0 src/php_pq_misc.c | 2 +- src/php_pq_module.c | 15 ++------------- src/php_pqconn.c | 4 ++-- src/php_pqcur.c | 4 ++-- src/php_pqres.c | 15 +++++++++------ tests/conv001.phpt | 2 +- 7 files changed, 17 insertions(+), 25 deletions(-) rename gen_pg_type.sh => gen_pq_type.sh (100%) diff --git a/gen_pg_type.sh b/gen_pq_type.sh similarity index 100% rename from gen_pg_type.sh rename to gen_pq_type.sh diff --git a/src/php_pq_misc.c b/src/php_pq_misc.c index 9ca158e..ab90936 100644 --- a/src/php_pq_misc.c +++ b/src/php_pq_misc.c @@ -162,7 +162,7 @@ PHP_MINIT_FUNCTION(pq_misc) { zend_class_entry **json, ce = {0}; - INIT_NS_CLASS_ENTRY(ce, "pq", "ConverterInterface", php_pqconv_methods); + INIT_NS_CLASS_ENTRY(ce, "pq", "Converter", php_pqconv_methods); php_pqconv_class_entry = zend_register_internal_interface(&ce TSRMLS_CC); memset(&ce, 0, sizeof(ce)); diff --git a/src/php_pq_module.c b/src/php_pq_module.c index 7864304..1fe68f5 100644 --- a/src/php_pq_module.c +++ b/src/php_pq_module.c @@ -20,18 +20,6 @@ #include -/* -#include -#include -#include -#include -#include - -#include -#include -#include -*/ - #include "php_pq.h" #include "php_pq_misc.h" #include "php_pqcancel.h" @@ -114,13 +102,14 @@ static PHP_MINFO_FUNCTION(pq) php_info_print_table_end(); } -const zend_function_entry pq_functions[] = { +static const zend_function_entry pq_functions[] = { {0} }; static zend_module_dep pq_module_deps[] = { ZEND_MOD_REQUIRED("raphf") ZEND_MOD_REQUIRED("spl") + ZEND_MOD_OPTIONAL("json") ZEND_MOD_END }; diff --git a/src/php_pqconn.c b/src/php_pqconn.c index e869d92..daf2c79 100644 --- a/src/php_pqconn.c +++ b/src/php_pqconn.c @@ -1851,7 +1851,7 @@ static int apply_set_converter(void *p TSRMLS_DC, int argc, va_list argv, zend_h } ZEND_BEGIN_ARG_INFO_EX(ai_pqconn_set_converter, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, converter, pq\\ConverterInterface, 0) + ZEND_ARG_OBJ_INFO(0, converter, pq\\Converter, 0) ZEND_END_ARG_INFO(); static PHP_METHOD(pqconn, setConverter) { STATUS rv; @@ -1882,7 +1882,7 @@ static PHP_METHOD(pqconn, setConverter) { } ZEND_BEGIN_ARG_INFO_EX(ai_pqconn_unset_converter, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, converter, pq\\ConverterInterface, 0) + ZEND_ARG_OBJ_INFO(0, converter, pq\\Converter, 0) ZEND_END_ARG_INFO(); static PHP_METHOD(pqconn, unsetConverter) { STATUS rv; diff --git a/src/php_pqcur.c b/src/php_pqcur.c index 00ad2b8..19c31a9 100644 --- a/src/php_pqcur.c +++ b/src/php_pqcur.c @@ -108,8 +108,8 @@ static void php_pqcur_object_free(void *o TSRMLS_DC) fprintf(stderr, "FREE cur(#%d) %p (conn: %p)\n", obj->zv.handle, obj, obj->intern->conn); #endif if (obj->intern) { - //cur_close(obj TSRMLS_CC); - //php_pq_object_delref(obj->intern->conn TSRMLS_CC); + cur_close(obj TSRMLS_CC); + php_pq_object_delref(obj->intern->conn TSRMLS_CC); efree(obj->intern->decl); efree(obj->intern->name); efree(obj->intern); diff --git a/src/php_pqres.c b/src/php_pqres.c index 88a2268..2c75655 100644 --- a/src/php_pqres.c +++ b/src/php_pqres.c @@ -655,8 +655,14 @@ ZEND_BEGIN_ARG_INFO_EX(ai_pqres_bind, 0, 0, 2) ZEND_END_ARG_INFO(); static PHP_METHOD(pqres, bind) { zval *zcol, *zref; + zend_error_handling zeh; + STATUS rv; - if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/z", &zcol, &zref)) { + zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC); + rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/z", &zcol, &zref); + zend_restore_error_handling(&zeh TSRMLS_CC); + + if (SUCCESS == rv) { php_pqres_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); if (!obj->intern) { @@ -811,9 +817,7 @@ static PHP_METHOD(pqres, fetchCol) { zend_replace_error_handling(EH_THROW, exce(EX_RUNTIME), &zeh TSRMLS_CC); php_pqres_iteration(getThis(), obj, obj->intern->iter ? obj->intern->iter->fetch_type : 0, &row TSRMLS_CC); - if (!row) { - RETVAL_FALSE; - } else { + if (row) { php_pqres_col_t col; if (SUCCESS != column_nn(obj, zcol, &col TSRMLS_CC)) { @@ -856,7 +860,6 @@ static PHP_METHOD(pqres, fetchAllCols) { php_pqres_col_t col; zend_replace_error_handling(EH_THROW, exce(EX_RUNTIME), &zeh TSRMLS_CC); - if (SUCCESS == column_nn(obj, zcol, &col TSRMLS_CC)) { int r, rows = PQntuples(obj->intern->res); @@ -865,7 +868,6 @@ static PHP_METHOD(pqres, fetchAllCols) { add_next_index_zval(return_value, php_pqres_get_col(obj->intern, r, col.num TSRMLS_CC)); } } - zend_restore_error_handling(&zeh TSRMLS_CC); } } @@ -1193,6 +1195,7 @@ PHP_MINIT_FUNCTION(pqres) zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_SCALAR"), PHP_PQRES_CONV_SCALAR TSRMLS_CC); zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_ARRAY"), PHP_PQRES_CONV_ARRAY TSRMLS_CC); zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_DATETIME"), PHP_PQRES_CONV_DATETIME TSRMLS_CC); + zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_JSON"), PHP_PQRES_CONV_JSON TSRMLS_CC); zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_ALL"), PHP_PQRES_CONV_ALL TSRMLS_CC); return SUCCESS; diff --git a/tests/conv001.phpt b/tests/conv001.phpt index f8eef52..27f41f1 100644 --- a/tests/conv001.phpt +++ b/tests/conv001.phpt @@ -12,7 +12,7 @@ echo "Test\n"; include "_setup.inc"; -abstract class Converter implements pq\ConverterInterface +abstract class Converter implements pq\Converter { protected $types;