update from docs
authorMichael Wallner <mike@php.net>
Mon, 6 Oct 2014 10:14:02 +0000 (12:14 +0200)
committerMichael Wallner <mike@php.net>
Mon, 6 Oct 2014 10:14:02 +0000 (12:14 +0200)
src/php_pqlob.c
src/php_pqres.c
src/php_pqstm.c

index 96b495e..755599e 100644 (file)
@@ -243,9 +243,12 @@ static PHP_METHOD(pqlob, __construct) {
        zend_restore_error_handling(&zeh TSRMLS_CC);
 
        if (SUCCESS == rv) {
+               php_pqlob_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
                php_pqtxn_object_t *txn_obj = zend_object_store_get_object(ztxn TSRMLS_CC);
 
-               if (!txn_obj->intern) {
+               if (obj->intern) {
+                       throw_exce(EX_BAD_METHODCALL TSRMLS_CC, "pq\\LOB already initialized");
+               } else if (!txn_obj->intern) {
                        throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Transaction not initialized");
                } else if (!txn_obj->intern->open) {
                        throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\Transation already closed");
@@ -262,8 +265,6 @@ static PHP_METHOD(pqlob, __construct) {
                                if (lofd < 0) {
                                        throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to open large object with oid=%u with mode '%s' (%s)", loid, strmode(mode), PHP_PQerrorMessage(txn_obj->intern->conn->intern->conn));
                                } else {
-                                       php_pqlob_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
                                        obj->intern = ecalloc(1, sizeof(*obj->intern));
                                        obj->intern->lofd = lofd;
                                        obj->intern->loid = loid;
index 9b35f21..d629d25 100644 (file)
@@ -1072,7 +1072,14 @@ static PHP_METHOD(pqres, fetchAll) {
 ZEND_BEGIN_ARG_INFO_EX(ai_pqres_count, 0, 0, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(pqres, count) {
-       if (SUCCESS == zend_parse_parameters_none()) {
+       zend_error_handling zeh;
+       STATUS rv;
+
+       zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
+       rv = zend_parse_parameters_none();
+       zend_restore_error_handling(&zeh TSRMLS_CC);
+
+       if (SUCCESS == rv) {
                long count;
 
                if (SUCCESS != php_pqres_count_elements(getThis(), &count TSRMLS_CC)) {
@@ -1086,7 +1093,14 @@ static PHP_METHOD(pqres, count) {
 ZEND_BEGIN_ARG_INFO_EX(ai_pqres_desc, 0, 0, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(pqres, desc) {
-       if (SUCCESS == zend_parse_parameters_none()) {
+       zend_error_handling zeh;
+       STATUS rv;
+
+       zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
+       rv = zend_parse_parameters_none();
+       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) {
index af0eb15..f3136d9 100644 (file)
@@ -112,7 +112,7 @@ static void php_pqstm_object_read_connection(zval *object, void *o, zval *return
 
 
 ZEND_BEGIN_ARG_INFO_EX(ai_pqstm_construct, 0, 0, 3)
-       ZEND_ARG_OBJ_INFO(0, Connection, pq\\Connection, 0)
+       ZEND_ARG_OBJ_INFO(0, connection, pq\\Connection, 0)
        ZEND_ARG_INFO(0, name)
        ZEND_ARG_INFO(0, query)
        ZEND_ARG_ARRAY_INFO(0, types, 1)
@@ -134,7 +134,9 @@ static PHP_METHOD(pqstm, __construct) {
                php_pqstm_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
                php_pqconn_object_t *conn_obj = zend_object_store_get_object(zconn TSRMLS_CC);
 
-               if (!conn_obj->intern) {
+               if (obj->intern) {
+                       throw_exce(EX_BAD_METHODCALL TSRMLS_CC, "pq\\Statement already initialized");
+               } else if (!conn_obj->intern) {
                        throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Connection not initialized");
                } else {
                        php_pq_params_t *params = php_pq_params_init(&conn_obj->intern->converters, ztypes ? Z_ARRVAL_P(ztypes) : NULL, NULL TSRMLS_CC);