From 3239a565260ae7a1cb6cfdaed532a61574f9e955 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sun, 20 Feb 2005 15:28:09 +0000 Subject: [PATCH] - Only call the ctor once --- ext/pdo/pdo_stmt.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 7518cc23d7..aaa3a71f89 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -713,20 +713,32 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, zend_update_property(ce, return_value, stmt->columns[i].name, stmt->columns[i].namelen, val TSRMLS_CC); - if (ce->constructor) { - stmt->fetch.cls.fci.object_pp = &return_value; - stmt->fetch.cls.fcc.object_pp = &return_value; - if (zend_call_function(&stmt->fetch.cls.fci, &stmt->fetch.cls.fcc TSRMLS_CC) == FAILURE) { - zend_throw_exception_ex(pdo_exception_ce, 0 TSRMLS_CC, "Could not execute %s::%s()", ce->name, ce->constructor->common.function_name); - } else { - if (stmt->fetch.cls.retval_ptr) { - zval_ptr_dtor(&stmt->fetch.cls.retval_ptr); - } - } - } + break; + + default: + pdo_raise_impl_error(stmt->dbh, stmt, "22003", "mode is out of range" TSRMLS_CC); break; } } + + switch (how) { + case PDO_FETCH_CLASS: + if (ce->constructor) { + stmt->fetch.cls.fci.object_pp = &return_value; + stmt->fetch.cls.fcc.object_pp = &return_value; + if (zend_call_function(&stmt->fetch.cls.fci, &stmt->fetch.cls.fcc TSRMLS_CC) == FAILURE) { + zend_throw_exception_ex(pdo_exception_ce, 0 TSRMLS_CC, "Could not execute %s::%s()", ce->name, ce->constructor->common.function_name); + } else { + if (stmt->fetch.cls.retval_ptr) { + zval_ptr_dtor(&stmt->fetch.cls.retval_ptr); + } + } + } + break; + + default: + break; + } } return 1; -- 2.50.1