X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-pq;a=blobdiff_plain;f=src%2Fphp_pqstm.c;h=ba1203721bcbeaf547cb16b3d128bec6012965bb;hp=af0eb15ea8c9707e69e09b64abaf913835205fa2;hb=da7b5981c5ae28504434c492d468913645111d66;hpb=19011ee23e5bdb9a46778e190a61e4ce6c765be7;ds=sidebyside diff --git a/src/php_pqstm.c b/src/php_pqstm.c index af0eb15..ba12037 100644 --- a/src/php_pqstm.c +++ b/src/php_pqstm.c @@ -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); @@ -248,8 +250,10 @@ static PHP_METHOD(pqstm, execAsync) { if (!rc) { throw_exce(EX_IO TSRMLS_CC, "Failed to execute statement (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn)); +#if HAVE_PQSETSINGLEROWMODE } else if (obj->intern->conn->intern->unbuffered && !PQsetSingleRowMode(obj->intern->conn->intern->conn)) { throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to enable unbuffered mode (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn)); +#endif } else { php_pq_callback_recurse(&obj->intern->conn->intern->onevent, &resolver TSRMLS_CC); obj->intern->conn->intern->poller = PQconsumeInput;