cvs: pecl /pdo pdo_dbh.c pdo_stmt.c php_pdo_driver.h /pdo/tests bug_36428.phpt
helly Fri Feb 24 15:56:03 2006 UTC
Added files:
/pecl/pdo/tests bug_36428.phpt
Modified files:
/pecl/pdo pdo_dbh.c pdo_stmt.c php_pdo_driver.h
Log:
- Add FETCH_PROPSLATE: fetch props after calling ctor
# Fixes bug #36428
http://cvs.php.net/viewcvs.cgi/pecl/pdo/pdo_dbh.c?r1=1.113&r2=1.114&diff_format=u
Index: pecl/pdo/pdo_dbh.c
diff -u pecl/pdo/pdo_dbh.c:1.113 pecl/pdo/pdo_dbh.c:1.114
--- pecl/pdo/pdo_dbh.c:1.113 Tue Feb 21 20:12:42 2006
+++ pecl/pdo/pdo_dbh.c Fri Feb 24 15:56:03 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_dbh.c,v 1.113 2006/02/21 20:12:42 dmitry Exp $ */
+/* $Id: pdo_dbh.c,v 1.114 2006/02/24 15:56:03 helly Exp $ */
/* The PDO Database Handle Class */
@@ -1238,6 +1238,7 @@
#if PHP_MAJOR_VERSION > 5 || PHP_MINOR_VERSION >= 1
REGISTER_PDO_CLASS_CONST_LONG("FETCH_SERIALIZE",(long)PDO_FETCH_SERIALIZE);
#endif
+ REGISTER_PDO_CLASS_CONST_LONG("FETCH_PROPSLATE",(long)PDO_FETCH_PROPSLATE);
REGISTER_PDO_CLASS_CONST_LONG("FETCH_NAMED",(long)PDO_FETCH_NAMED);
REGISTER_PDO_CLASS_CONST_LONG("ATTR_AUTOCOMMIT", (long)PDO_ATTR_AUTOCOMMIT);
http://cvs.php.net/viewcvs.cgi/pecl/pdo/pdo_stmt.c?r1=1.146&r2=1.147&diff_format=u
Index: pecl/pdo/pdo_stmt.c
diff -u pecl/pdo/pdo_stmt.c:1.146 pecl/pdo/pdo_stmt.c:1.147
--- pecl/pdo/pdo_stmt.c:1.146 Tue Feb 21 20:12:42 2006
+++ pecl/pdo/pdo_stmt.c Fri Feb 24 15:56:03 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_stmt.c,v 1.146 2006/02/21 20:12:42 dmitry Exp $ */
+/* $Id: pdo_stmt.c,v 1.147 2006/02/24 15:56:03 helly Exp $ */
/* The PDO Statement Handle Class */
@@ -838,6 +838,18 @@
return 0;
}
}
+ if (ce->constructor && (flags & PDO_FETCH_PROPSLATE)) {
+ 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) {
+ pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call class
constructor" TSRMLS_CC);
+ return 0;
+ } else {
+ if (stmt->fetch.cls.retval_ptr) {
+ zval_ptr_dtor(&stmt->fetch.cls.retval_ptr);
+ }
+ }
+ }
}
break;
@@ -1000,7 +1012,7 @@
switch (how) {
case PDO_FETCH_CLASS:
- if (ce->constructor) {
+ if (ce->constructor && !(flags & PDO_FETCH_PROPSLATE)) {
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) {
http://cvs.php.net/viewcvs.cgi/pecl/pdo/php_pdo_driver.h?r1=1.74&r2=1.75&diff_format=u
Index: pecl/pdo/php_pdo_driver.h
diff -u pecl/pdo/php_pdo_driver.h:1.74 pecl/pdo/php_pdo_driver.h:1.75
--- pecl/pdo/php_pdo_driver.h:1.74 Wed Feb 1 09:10:23 2006
+++ pecl/pdo/php_pdo_driver.h Fri Feb 24 15:56:03 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pdo_driver.h,v 1.74 2006/02/01 09:10:23 tony2001 Exp $ */
+/* $Id: php_pdo_driver.h,v 1.75 2006/02/24 15:56:03 helly Exp $ */
#ifndef PHP_PDO_DRIVER_H
#define PHP_PDO_DRIVER_H
@@ -98,6 +98,7 @@
#define PDO_FETCH_UNIQUE 0x00030000 /* fetch into groups assuming first col is unique */
#define PDO_FETCH_CLASSTYPE 0x00040000 /* fetch class gets its class name from 1st column */
#define PDO_FETCH_SERIALIZE 0x00080000 /* fetch class instances by calling serialize */
+#define PDO_FETCH_PROPSLATE 0x00100000 /* fetch props after calling ctor */
/* fetch orientation for scrollable cursors */
enum pdo_fetch_orientation {
http://cvs.php.net/viewcvs.cgi/pecl/pdo/tests/bug_36428.phpt?view=markup&rev=1.1
Index: pecl/pdo/tests/bug_36428.phpt
+++ pecl/pdo/tests/bug_36428.phpt
--TEST--
PDO Common: PHP Bug #36428: Incorrect error message for PDO::fetchAll
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded('pdo')) die('skip');
if (!extension_loaded('simplexml')) die('skip SimpleXML not loaded');
$dir = getenv('REDIR_TEST_DIR');
if (false == $dir) die('skip no driver');
require_once $dir . 'pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
if (getenv('REDIR_TEST_DIR') === false)
putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
$db = PDOTest::factory();
$db->exec("CREATE TABLE test (a VARCHAR(10))");
$db->exec("INSERT INTO test (a) VALUES ('xyz')");
$res = $db->query("SELECT a FROM test");
var_dump($res->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_PROPSLATE, 'SimpleXMLElement',
array('<root/>')));
?>
===DONE===
--EXPECTF--
array(1) {
[0]=>
object(SimpleXMLElement)#%d (1) {
["a"]=>
string(3) "xyz"
}
}
===DONE===
Thread (1 message)
- Marcus Boerger