]> granicus.if.org Git - php/commitdiff
MFH: Fix get_parent_class() of PDORow instances
authorJohannes Schlüter <johannes@php.net>
Mon, 3 Mar 2008 19:00:45 +0000 (19:00 +0000)
committerJohannes Schlüter <johannes@php.net>
Mon, 3 Mar 2008 19:00:45 +0000 (19:00 +0000)
ext/pdo/pdo_stmt.c
ext/pdo/tests/pdo_035.phpt [new file with mode: 0644]

index 45b1b6c0e357c095b700ad839946a08611120524..356962de1d428a3a9c6bfa5af52a1ba988adea2a 100755 (executable)
@@ -2675,9 +2675,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 = 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 (file)
index 0000000..c35c504
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+PDO Common: PDORow + get_parent_class()
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo_sqlite')) die ("skip Need PDO_SQlite support");
+?>
+--FILE--
+<?php
+$db = new PDO('sqlite::memory:');
+$db->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)