+++ /dev/null
-#!/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
--- /dev/null
+#!/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
{
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));
#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"
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
};
}
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;
}
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;
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);
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) {
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)) {
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);
add_next_index_zval(return_value, php_pqres_get_col(obj->intern, r, col.num TSRMLS_CC));
}
}
-
zend_restore_error_handling(&zeh TSRMLS_CC);
}
}
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;
include "_setup.inc";
-abstract class Converter implements pq\ConverterInterface
+abstract class Converter implements pq\Converter
{
protected $types;