update from docs
authorMichael Wallner <mike@php.net>
Thu, 25 Sep 2014 12:04:35 +0000 (14:04 +0200)
committerMichael Wallner <mike@php.net>
Thu, 25 Sep 2014 12:04:35 +0000 (14:04 +0200)
gen_pg_type.sh [deleted file]
gen_pq_type.sh [new file with mode: 0755]
src/php_pq_misc.c
src/php_pq_module.c
src/php_pqconn.c
src/php_pqcur.c
src/php_pqres.c
tests/conv001.phpt

diff --git a/gen_pg_type.sh b/gen_pg_type.sh
deleted file mode 100755 (executable)
index 561dc0a..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-CWD=$(dirname $0)
-awk -f $CWD/php_pq_type.awk >$CWD/php_pq_type.h \
-       </usr/include/postgresql/server/catalog/pg_type.h
diff --git a/gen_pq_type.sh b/gen_pq_type.sh
new file mode 100755 (executable)
index 0000000..561dc0a
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+CWD=$(dirname $0)
+awk -f $CWD/php_pq_type.awk >$CWD/php_pq_type.h \
+       </usr/include/postgresql/server/catalog/pg_type.h
index 9ca158e43bbf97041151a577dd56316352be046a..ab90936428f20377d81c5ff84fdd915669c6ab07 100644 (file)
@@ -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));
index 786430429b136319020f2de0ae1314da31336a54..1fe68f5e4ce5270672ab3692418fee9806668d95 100644 (file)
 
 #include <libpq-fe.h>
 
-/*
-#include <Zend/zend_interfaces.h>
-#include <Zend/zend_exceptions.h>
-#include <ext/spl/spl_array.h>
-#include <ext/spl/spl_exceptions.h>
-#include <ext/raphf/php_raphf.h>
-
-#include <libpq-events.h>
-#include <libpq/libpq-fs.h>
-#include <fnmatch.h>
-*/
-
 #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
 };
 
index e869d92acd9000ac7f8a2c10561cc96ceb2bca7d..daf2c7947b92821ac0560a3e1b7ae3fdc77fcbe1 100644 (file)
@@ -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;
index 00ad2b83d63c09c9cb761543b65ad74744111b23..19c31a958b59451e981fe00d22d9b767c80a8160 100644 (file)
@@ -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);
index 88a226835e05460bac640b43595903f4b3b1dd22..2c756558fef2bc1800b6154e8469e7681a113098 100644 (file)
@@ -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;
index f8eef52a7583e8f8bd17a5d816c1c9da3dbc868a..27f41f11af5c1b270070da326d978d1be9aafba5 100644 (file)
@@ -12,7 +12,7 @@ echo "Test\n";
 
 include "_setup.inc";
 
-abstract class Converter implements pq\ConverterInterface
+abstract class Converter implements pq\Converter
 {
        protected $types;