From: Michael Wallner Date: Thu, 25 Sep 2014 12:04:35 +0000 (+0200) Subject: update from docs X-Git-Tag: v0.5.0~15 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=753359f19c5d29f08faca43ee735c49c217230a7;p=m6w6%2Fext-pq update from docs --- diff --git a/gen_pg_type.sh b/gen_pg_type.sh deleted file mode 100755 index 561dc0a..0000000 --- a/gen_pg_type.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -CWD=$(dirname $0) -awk -f $CWD/php_pq_type.awk >$CWD/php_pq_type.h \ - $CWD/php_pq_type.h \ + -/* -#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; + + 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 == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/z", &zcol, &zref)) { + 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;