From 237ad54d4caf978e009a5d43fe63af5d9665cc11 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Schl=C3=BCter?= Date: Mon, 3 Mar 2008 18:58:59 +0000 Subject: [PATCH] - Fix get_parent_class() of PDORow instances --- ext/pdo/pdo_stmt.c | 10 +++++++--- ext/pdo/tests/pdo_035.phpt | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 ext/pdo/tests/pdo_035.phpt diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 2b9ff4f26d..a6eab0f060 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2674,9 +2674,13 @@ static zend_class_entry *row_get_ce(zval *object TSRMLS_DC) static int row_get_classname(zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC) { - *class_name = estrndup("PDORow", sizeof("PDORow")-1); - *class_name_len = sizeof("PDORow")-1; - return 0; + if (parent) { + return FAILURE; + } else { + *class_name = UG(unicode) ? USTR_MAKE("PDORow") : estrndup("PDORow", sizeof("PDORow")-1); + *class_name_len = sizeof("PDORow")-1; + return SUCCESS; + } } static int row_compare(zval *object1, zval *object2 TSRMLS_DC) diff --git a/ext/pdo/tests/pdo_035.phpt b/ext/pdo/tests/pdo_035.phpt new file mode 100644 index 0000000000..37d5a875b1 --- /dev/null +++ b/ext/pdo/tests/pdo_035.phpt @@ -0,0 +1,22 @@ +--TEST-- +PDO Common: PDORow and get_parent_class() +--SKIPIF-- + +--FILE-- +exec('CREATE TABLE test (id int)'); +$db->exec('INSERT INTO test VALUES (23)'); + +$stmt = $db->prepare('SELECT id FROM test'); +$stmt->execute(); +$result = $stmt->fetch(PDO::FETCH_LAZY); + +echo get_class($result), "\n"; +var_dump(get_parent_class($result)); +?> +--EXPECT-- +PDORow +bool(false) -- 2.50.1