From: Wez Furlong Date: Thu, 20 May 2004 22:06:42 +0000 (+0000) Subject: Implement PDO_FETCH_OBJ X-Git-Tag: RELEASE_0_1~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e0ac3f66aeff5c80859bce6e81dbb22231cf84fd;p=php Implement PDO_FETCH_OBJ # todo (after initial release) - specify a particular class, reuse existing # objects etc. --- diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 9849f3b53c..0321faa515 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -399,6 +399,8 @@ static int do_fetch_common(pdo_stmt_t *stmt, int do_bind TSRMLS_DC) * If return_value is not null, store values into it according to HOW. */ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_fetch_type how TSRMLS_DC) { + enum pdo_fetch_type really_how = how; + if (!do_fetch_common(stmt, do_bind TSRMLS_CC)) { return 0; } @@ -408,7 +410,9 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_ array_init(return_value); - if (how == PDO_FETCH_LAZY || how == PDO_FETCH_OBJ) { + if (how == PDO_FETCH_OBJ) { + how = PDO_FETCH_ASSOC; + } else if (how == PDO_FETCH_LAZY) { how = PDO_FETCH_BOTH; } @@ -428,6 +432,10 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_ ZVAL_ADDREF(val); } } + + if (really_how == PDO_FETCH_OBJ) { + object_and_properties_init(return_value, ZEND_STANDARD_CLASS_DEF_PTR, Z_ARRVAL_P(return_value)); + } } return 1;