From 94be2af75078af30116718bb2df201d9e5a47e5b Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 26 Sep 2014 15:05:40 +0200 Subject: [PATCH] update from docs --- src/php_pqconn.c | 2 +- src/php_pqres.c | 2 +- src/php_pqstm.c | 8 +++++++- src/php_pqtxn.c | 2 +- src/php_pqtypes.c | 6 +++++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/php_pqconn.c b/src/php_pqconn.c index daf2c79..b978bb0 100644 --- a/src/php_pqconn.c +++ b/src/php_pqconn.c @@ -1970,7 +1970,7 @@ PHP_MINIT_FUNCTION(pqconn) php_pqconn_object_handlers.get_properties = php_pq_object_properties; php_pqconn_object_handlers.get_debug_info = php_pq_object_debug_info; - zend_hash_init(&php_pqconn_object_prophandlers, 14, NULL, NULL, 1); + zend_hash_init(&php_pqconn_object_prophandlers, 19, NULL, NULL, 1); zend_declare_property_long(php_pqconn_class_entry, ZEND_STRL("status"), CONNECTION_BAD, ZEND_ACC_PUBLIC TSRMLS_CC); ph.read = php_pqconn_object_read_status; diff --git a/src/php_pqres.c b/src/php_pqres.c index 2c75655..0197732 100644 --- a/src/php_pqres.c +++ b/src/php_pqres.c @@ -1136,7 +1136,7 @@ PHP_MINIT_FUNCTION(pqres) php_pqres_object_handlers.get_properties = php_pq_object_properties; php_pqres_object_handlers.count_elements = php_pqres_count_elements; - zend_hash_init(&php_pqres_object_prophandlers, 6, NULL, NULL, 1); + zend_hash_init(&php_pqres_object_prophandlers, 8, NULL, NULL, 1); zend_declare_property_null(php_pqres_class_entry, ZEND_STRL("status"), ZEND_ACC_PUBLIC TSRMLS_CC); ph.read = php_pqres_object_read_status; diff --git a/src/php_pqstm.c b/src/php_pqstm.c index d9ec1ea..4b71038 100644 --- a/src/php_pqstm.c +++ b/src/php_pqstm.c @@ -165,8 +165,14 @@ ZEND_END_ARG_INFO(); static PHP_METHOD(pqstm, bind) { long param_no; zval *param_ref; + 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, "lz", ¶m_no, ¶m_ref); + zend_restore_error_handling(&zeh TSRMLS_CC); - if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz", ¶m_no, ¶m_ref)) { + if (SUCCESS == rv) { php_pqstm_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); if (!obj->intern) { diff --git a/src/php_pqtxn.c b/src/php_pqtxn.c index fcf7a4b..5fc1e9d 100644 --- a/src/php_pqtxn.c +++ b/src/php_pqtxn.c @@ -355,7 +355,7 @@ static PHP_METHOD(pqtxn, commit) { if (!obj->intern) { throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Transacation not initialized"); } else if (!obj->intern->open) { - throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\Transacation already closed"); + throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\Transaction already closed"); } else { PGresult *res; smart_str cmd = {0}; diff --git a/src/php_pqtypes.c b/src/php_pqtypes.c index ff9c10d..8f4b53d 100644 --- a/src/php_pqtypes.c +++ b/src/php_pqtypes.c @@ -207,7 +207,7 @@ static PHP_METHOD(pqtypes, __construct) { obj->intern = ecalloc(1, sizeof(*obj->intern)); obj->intern->conn = conn_obj; php_pq_object_addref(conn_obj TSRMLS_CC); - zend_hash_init(&obj->intern->types, 300, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(&obj->intern->types, 512, NULL, ZVAL_PTR_DTOR, 0); if (znsp) { zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "refresh", &retval, znsp); @@ -337,6 +337,10 @@ PHP_MINIT_FUNCTION(pqtypes) php_pqtypes_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC); php_pqtypes_class_entry->create_object = php_pqtypes_create_object; + /* + zend_class_implements(php_pqtypes_class_entry TSRMLS_CC, 1, zend_ce_arrayaccess); + */ + memcpy(&php_pqtypes_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); php_pqtypes_object_handlers.read_property = php_pq_object_read_prop; php_pqtypes_object_handlers.write_property = php_pq_object_write_prop; -- 2.30.2