]> granicus.if.org Git - php/commitdiff
- Only call the ctor once
authorMarcus Boerger <helly@php.net>
Sun, 20 Feb 2005 15:28:09 +0000 (15:28 +0000)
committerMarcus Boerger <helly@php.net>
Sun, 20 Feb 2005 15:28:09 +0000 (15:28 +0000)
ext/pdo/pdo_stmt.c

index 7518cc23d7b2167f9d8f40f96e5e0b0663d8ed2a..aaa3a71f8929a2df123cafd33e82d6aa7c95400e 100755 (executable)
@@ -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;