]> granicus.if.org Git - php/commitdiff
- Delay ctor call so that it can overwrite everything and the data can
authorMarcus Boerger <helly@php.net>
Wed, 23 Feb 2005 23:28:30 +0000 (23:28 +0000)
committerMarcus Boerger <helly@php.net>
Wed, 23 Feb 2005 23:28:30 +0000 (23:28 +0000)
  already be accessed from the ctor.

ext/pdo/pdo_dbh.c
ext/pdo_mysql/tests/pdo_mysql_014.phpt
ext/pdo_pgsql/tests/pdo_pgsql_014.phpt
ext/pdo_sqlite/tests/pdo_sqlite_014.phpt

index ec9cf50e99b8fdb51b4e5f16fc08691eb085c0cc..e979cc06ac8fe88b30d8c7812f675c4992dc7e38 100755 (executable)
@@ -385,7 +385,7 @@ static PHP_FUNCTION(dbh_constructor)
 }
 /* }}} */
 
-static zval * pdo_instanciate_stmt(zval *object, zend_class_entry *dbstmt_ce, zval *ctor_args TSRMLS_DC) /* {{{ */
+static zval * pdo_stmt_instanciate(zval *object, zend_class_entry *dbstmt_ce, zval *ctor_args TSRMLS_DC) /* {{{ */
 {
        if (ctor_args) {
                if (Z_TYPE_P(ctor_args) != IS_ARRAY) {
@@ -403,6 +403,11 @@ static zval * pdo_instanciate_stmt(zval *object, zend_class_entry *dbstmt_ce, zv
        object->refcount = 1;
        object->is_ref = 1;
        
+       return object;
+} /* }}} */
+
+static void pdo_stmt_construct(zval *object, zend_class_entry *dbstmt_ce, zval *ctor_args TSRMLS_DC) /* {{{ */
+{      
        if (dbstmt_ce->constructor) {
                zend_fcall_info fci;
                zend_fcall_info_cache fcc;
@@ -448,8 +453,6 @@ static zval * pdo_instanciate_stmt(zval *object, zend_class_entry *dbstmt_ce, zv
                        efree(fci.params);
                }
        }
-
-       return object;
 }
 /* }}} */
 
@@ -502,7 +505,7 @@ static PHP_METHOD(PDO, prepare)
                ctor_args = NULL;
        }
 
-       if (!pdo_instanciate_stmt(return_value, dbstmt_ce, ctor_args TSRMLS_CC)) {
+       if (!pdo_stmt_instanciate(return_value, dbstmt_ce, ctor_args TSRMLS_CC)) {
                zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "Failed to instanciate statement class %s", dbstmt_ce->name);
                return;
        }
@@ -520,7 +523,7 @@ static PHP_METHOD(PDO, prepare)
        ZVAL_NULL(&stmt->lazy_object_ref);
 
        if (dbh->methods->preparer(dbh, statement, statement_len, stmt, options TSRMLS_CC)) {
-
+               pdo_stmt_construct(return_value, dbstmt_ce, ctor_args TSRMLS_CC);
                return;
        }
 
@@ -818,7 +821,7 @@ static PHP_METHOD(PDO, query)
        
        PDO_DBH_CLEAR_ERR();
 
-       if (!pdo_instanciate_stmt(return_value, pdo_dbstmt_ce, NULL TSRMLS_CC)) {
+       if (!pdo_stmt_instanciate(return_value, pdo_dbstmt_ce, NULL TSRMLS_CC)) {
                zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "Failed to instanciate statement class %s", pdo_dbstmt_ce->name);
                return;
        }
@@ -852,6 +855,7 @@ static PHP_METHOD(PDO, query)
                                        stmt->executed = 1;
                                }
                                if (ret) {
+                                       pdo_stmt_construct(return_value, pdo_dbstmt_ce, NULL TSRMLS_CC);
                                        return;
                                }
                        }
index 493a1f740cca3f774a544321ed68b1b302004025..c268ad00d4c6903cd422502cc766bc832115dee4 100755 (executable)
@@ -35,23 +35,15 @@ NULL
 bool(false)
 PDOStatementAggregate::__construct
 PDOStatementAggregate::getIterator
-array(4) {
-  ["val"]=>
-  string(1) "A"
+array(2) {
   [0]=>
   string(1) "A"
-  ["grp"]=>
-  string(6) "Group1"
   [1]=>
   string(6) "Group1"
 }
-array(4) {
-  ["val"]=>
-  string(1) "B"
+array(2) {
   [0]=>
   string(1) "B"
-  ["grp"]=>
-  string(6) "Group2"
   [1]=>
   string(6) "Group2"
 }
index 9a622d3b7efbf0ba2eb3860f9fc0e87f4033b762..74cf077bdf391595c7c9a55436cb72a688017bab 100755 (executable)
@@ -35,23 +35,15 @@ NULL
 bool(false)
 PDOStatementAggregate::__construct
 PDOStatementAggregate::getIterator
-array(4) {
-  ["val"]=>
-  string(1) "A"
+array(2) {
   [0]=>
   string(1) "A"
-  ["grp"]=>
-  string(6) "Group1"
   [1]=>
   string(6) "Group1"
 }
-array(4) {
-  ["val"]=>
-  string(1) "B"
+array(2) {
   [0]=>
   string(1) "B"
-  ["grp"]=>
-  string(6) "Group2"
   [1]=>
   string(6) "Group2"
 }
index 193019c94829a199722456cea54d52277e0b1b1a..a9441a2f18340f2b5616a9cbe59d762ae245cec7 100755 (executable)
@@ -35,23 +35,15 @@ NULL
 bool(false)
 PDOStatementAggregate::__construct
 PDOStatementAggregate::getIterator
-array(4) {
-  ["val"]=>
-  string(1) "A"
+array(2) {
   [0]=>
   string(1) "A"
-  ["grp"]=>
-  string(6) "Group1"
   [1]=>
   string(6) "Group1"
 }
-array(4) {
-  ["val"]=>
-  string(1) "B"
+array(2) {
   [0]=>
   string(1) "B"
-  ["grp"]=>
-  string(6) "Group2"
   [1]=>
   string(6) "Group2"
 }