[PHP-CVS] svn: /php/php-src/branches/PHP_5_3/ext/pdo/ pdo_stmt.c

2011-02-22 Thread Ilia Alshanetsky
iliaaTue, 22 Feb 2011 15:48:25 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=308569

Log:
Fixed compiler warning

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c

Modified: php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c
===
--- php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c 2011-02-22 14:49:32 UTC 
(rev 308568)
+++ php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c 2011-02-22 15:48:25 UTC 
(rev 308569)
@@ -2183,7 +2183,7 @@
php_stream_printf(out TSRMLS_CC, Key: Name: 
[%d] %.*s\n, len, len, str);
}

-   php_stream_printf(out TSRMLS_CC, paramno=%d\nname=[%d] 
\%.*s\\nis_param=%d\nparam_type=%d\n,
+   php_stream_printf(out TSRMLS_CC, 
paramno=%ld\nname=[%d] \%.*s\\nis_param=%d\nparam_type=%d\n,
param-paramno, param-namelen, param-namelen, 
param-name ? param-name : ,
param-is_param,
param-param_type);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/pdo/pdo_stmt.c trunk/ext/pdo/pdo_stmt.c

2010-11-15 Thread Felipe Pena
felipe   Mon, 15 Nov 2010 18:48:48 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=305381

Log:
- Fix wrong argument to read_property call

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c
U   php/php-src/trunk/ext/pdo/pdo_stmt.c

Modified: php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c
===
--- php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c 2010-11-15 18:46:59 UTC 
(rev 305380)
+++ php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c 2010-11-15 18:48:48 UTC 
(rev 305381)
@@ -2621,7 +2621,7 @@
}
if (strcmp(Z_STRVAL_P(member), queryString) == 0) {
zval_ptr_dtor(return_value);
-   return 
std_object_handlers.read_property(object, member, IS_STRING TSRMLS_CC);
+   return 
std_object_handlers.read_property(object, member, type TSRMLS_CC);
}
}
}

Modified: php/php-src/trunk/ext/pdo/pdo_stmt.c
===
--- php/php-src/trunk/ext/pdo/pdo_stmt.c2010-11-15 18:46:59 UTC (rev 
305380)
+++ php/php-src/trunk/ext/pdo/pdo_stmt.c2010-11-15 18:48:48 UTC (rev 
305381)
@@ -2610,7 +2610,7 @@
}
if (strcmp(Z_STRVAL_P(member), queryString) == 0) {
zval_ptr_dtor(return_value);
-   return 
std_object_handlers.read_property(object, member, IS_STRING, key TSRMLS_CC);
+   return 
std_object_handlers.read_property(object, member, type, key TSRMLS_CC);
}
}
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/pdo/pdo_stmt.c branches/PHP_5_3/ext/pdo/tests/pdo_005.phpt branches/PHP_5_3/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt branches/PHP_5_3/ext/p

2010-02-11 Thread Johannes Schlüter
johannes Thu, 11 Feb 2010 22:14:06 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=294903

Log:
Revert 290786: Fixed bug #49521 (PDO fetchObject sets values before calling
constructor)

Bug: http://bugs.php.net/49521 (Closed) PDO fetchObject sets values before 
calling constructor
  
Changed paths:
U   php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c
U   php/php-src/branches/PHP_5_3/ext/pdo/tests/pdo_005.phpt
U   
php/php-src/branches/PHP_5_3/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt
D   php/php-src/branches/PHP_5_3/ext/pdo_sqlite/tests/bug49521.phpt
U   php/php-src/trunk/ext/pdo/pdo_stmt.c
U   php/php-src/trunk/ext/pdo/tests/pdo_005.phpt
U   php/php-src/trunk/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt
D   php/php-src/trunk/ext/pdo_sqlite/tests/bug49521.phpt

Modified: php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c
===
--- php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c	2010-02-11 22:13:22 UTC (rev 294902)
+++ php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c	2010-02-11 22:14:06 UTC (rev 294903)
@@ -1034,32 +1034,6 @@
 			}
 		}

-		switch (how) {
-			case PDO_FETCH_CLASS:
-if (ce-constructor  !(flags  (PDO_FETCH_PROPS_LATE | PDO_FETCH_SERIALIZE))) {
-	stmt-fetch.cls.fci.object_ptr = return_value;
-	stmt-fetch.cls.fcc.object_ptr = 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);
-		}
-	}
-}
-if (flags  PDO_FETCH_CLASSTYPE) {
-	do_fetch_opt_finish(stmt, 0 TSRMLS_CC);
-	stmt-fetch.cls.ce = old_ce;
-	stmt-fetch.cls.ctor_args = old_ctor_args;
-	stmt-fetch.cls.fci.param_count = old_arg_count;
-}
-break;
-
-			default:
-break;
-		}
-
 		for (idx = 0; i  stmt-column_count; i++, idx++) {
 			zval *val;
 			MAKE_STD_ZVAL(val);
@@ -1193,6 +1167,27 @@
 		}

 		switch (how) {
+			case PDO_FETCH_CLASS:
+if (ce-constructor  !(flags  (PDO_FETCH_PROPS_LATE | PDO_FETCH_SERIALIZE))) {
+	stmt-fetch.cls.fci.object_ptr = return_value;
+	stmt-fetch.cls.fcc.object_ptr = 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);
+		}
+	}
+}
+if (flags  PDO_FETCH_CLASSTYPE) {
+	do_fetch_opt_finish(stmt, 0 TSRMLS_CC);
+	stmt-fetch.cls.ce = old_ce;
+	stmt-fetch.cls.ctor_args = old_ctor_args;
+	stmt-fetch.cls.fci.param_count = old_arg_count;
+}
+break;
+
 			case PDO_FETCH_FUNC:
 stmt-fetch.func.fci.param_count = idx;
 stmt-fetch.func.fci.retval_ptr_ptr = retval;

Modified: php/php-src/branches/PHP_5_3/ext/pdo/tests/pdo_005.phpt
===
--- php/php-src/branches/PHP_5_3/ext/pdo/tests/pdo_005.phpt	2010-02-11 22:13:22 UTC (rev 294902)
+++ php/php-src/branches/PHP_5_3/ext/pdo/tests/pdo_005.phpt	2010-02-11 22:14:06 UTC (rev 294903)
@@ -34,7 +34,7 @@

 	public function __construct($row)
 	{
-		echo __METHOD__ . ($row)\n;
+		echo __METHOD__ . ($row,{$this-id})\n;
 		$this-row = $row++;
 	}
 }
@@ -108,9 +108,9 @@
 string(2) CC
   }
 }
-TestDerived::__construct(0)
-TestDerived::__construct(1)
-TestDerived::__construct(2)
+TestDerived::__construct(0,1)
+TestDerived::__construct(1,2)
+TestDerived::__construct(2,3)
 array(3) {
   [0]=
   object(TestDerived)#%d (5) {
@@ -151,4 +151,4 @@
 [val2]=
 string(2) CC
   }
-}
+}
\ No newline at end of file

Modified: php/php-src/branches/PHP_5_3/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt
===
--- php/php-src/branches/PHP_5_3/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt	2010-02-11 22:13:22 UTC (rev 294902)
+++ php/php-src/branches/PHP_5_3/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt	2010-02-11 22:14:06 UTC (rev 294903)
@@ -71,21 +71,21 @@
 MySQLPDOTest::dropTestTable();
 ?
 --EXPECTF--
-myclass::__construct(0, 1): 0 / 0
 myclass::__set(id, -'1'-) 1
 myclass::__set(, -''-) 2
 myclass::__set(null, -NULL-) 3
 myclass::__set(, -''-) 4
-myclass::__construct(1, 2): 4 / 0
+myclass::__construct(0, 1): 4 / 4
 myclass::__set(id, -'2'-) 1
 myclass::__set(, -''-) 2
 myclass::__set(null, -NULL-) 3
 myclass::__set(, -''-) 4
-myclass::__construct(2, 3): 8 / 0
+myclass::__construct(1, 2): 8 / 4
 myclass::__set(id, -'3'-) 1
 myclass::__set(, -''-) 2
 myclass::__set(null, -NULL-) 3
 myclass::__set(, -''-) 4
+myclass::__construct(2, 3): 12 / 4
 

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/pdo/pdo_stmt.c branches/PHP_5_3/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt trunk/ext/pdo/pdo_stmt.c trunk/ext/pdo_sqlite/tests/pdo_fetch_func_001.ph

2009-12-14 Thread Felipe Pena
felipe   Mon, 14 Dec 2009 21:44:56 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=292143

Log:
- Fixed memory leak when E_STRICT message is getted

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c
A   
php/php-src/branches/PHP_5_3/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
U   php/php-src/trunk/ext/pdo/pdo_stmt.c
A   php/php-src/trunk/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt

Modified: php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c
===
--- php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c	2009-12-14 21:29:08 UTC (rev 292142)
+++ php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c	2009-12-14 21:44:56 UTC (rev 292143)
@@ -795,6 +795,10 @@
 		}
 		return 0;
 	}
+	if (is_callable_error) {
+		/* Possible E_STRICT error message */
+		efree(is_callable_error);
+	}

 	fci-param_count = num_args; /* probably less */
 	fci-params = safe_emalloc(sizeof(zval**), num_args, 0);

Added: php/php-src/branches/PHP_5_3/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
===
--- php/php-src/branches/PHP_5_3/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt	(rev 0)
+++ php/php-src/branches/PHP_5_3/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt	2009-12-14 21:44:56 UTC (rev 292143)
@@ -0,0 +1,126 @@
+--TEST--
+Testing several callbacks using PDO::FETCH_FUNC
+--FILE--
+?php
+
+$db = new PDO('sqlite::memory:');
+$db-exec('CREATE TABLE testing (id INTEGER , name VARCHAR)');
+$db-exec('INSERT INTO testing VALUES(1, php)');
+$db-exec('INSERT INTO testing VALUES(2, )');
+
+$st = $db-query('SELECT * FROM testing');
+$st-fetchAll(PDO::FETCH_FUNC, function($x, $y) use ($st) { var_dump($st); print data: $x, $y\n; });
+
+$st = $db-query('SELECT name FROM testing');
+var_dump($st-fetchAll(PDO::FETCH_FUNC, 'strtoupper'));
+
+$st = $db-query('SELECT * FROM testing');
+var_dump($st-fetchAll(PDO::FETCH_FUNC, 'nothing'));
+
+$st = $db-query('SELECT * FROM testing');
+var_dump($st-fetchAll(PDO::FETCH_FUNC, ''));
+
+$st = $db-query('SELECT * FROM testing');
+var_dump($st-fetchAll(PDO::FETCH_FUNC, NULL));
+
+$st = $db-query('SELECT * FROM testing');
+var_dump($st-fetchAll(PDO::FETCH_FUNC, 1));
+
+$st = $db-query('SELECT * FROM testing');
+var_dump($st-fetchAll(PDO::FETCH_FUNC, array('self', 'foo')));
+
+class foo {
+	public function foo($x) {
+		return --- $x ---;
+	}
+}
+class bar extends foo {
+	public function __construct($db) {
+		$st = $db-query('SELECT * FROM testing');
+		var_dump($st-fetchAll(PDO::FETCH_FUNC, array($this, 'parent::foo')));
+	}
+
+	static public function test($x, $y) {
+		return $x .'---'. $y;
+	}
+
+	private function test2($x, $y) {
+		return $x;
+	}
+
+	public function test3($x, $y) {
+		return $x .'==='. $y;
+	}
+}
+
+new bar($db);
+
+$st = $db-query('SELECT * FROM testing');
+var_dump($st-fetchAll(PDO::FETCH_FUNC, array('bar', 'test')));
+
+$st = $db-query('SELECT * FROM testing');
+var_dump($st-fetchAll(PDO::FETCH_FUNC, array('bar', 'test2')));
+
+$st = $db-query('SELECT * FROM testing');
+var_dump($st-fetchAll(PDO::FETCH_FUNC, array('bar', 'test3')));
+
+$st = $db-query('SELECT * FROM testing');
+var_dump($st-fetchAll(PDO::FETCH_FUNC, array('bar', 'inexistent')));
+
+?
+--EXPECTF--
+object(PDOStatement)#%d (1) {
+  [%u|b%queryString]=
+  %string|unicode%(21) SELECT * FROM testing
+}
+data: 1, php
+object(PDOStatement)#%d (1) {
+  [%u|b%queryString]=
+  %string|unicode%(21) SELECT * FROM testing
+}
+data: 2,
+array(2) {
+  [0]=
+  %string|unicode%(3) PHP
+  [1]=
+  %string|unicode%(0) 
+}
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function 'nothing' not found or invalid function name in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function '' not found or invalid function name in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: cannot access self:: when no class scope is active in %s on line %d
+bool(false)
+array(2) {
+  [0]=
+  %string|unicode%(9) --- 1 ---
+  [1]=
+  %string|unicode%(9) --- 2 ---
+}
+array(2) {
+  [0]=
+  %string|unicode%(7) 1---php
+  [1]=
+  %string|unicode%(4) 2---
+}
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: cannot access private method bar::test2() in %s on line %d
+bool(false)
+array(2) {
+  [0]=
+  %string|unicode%(7) 1===php
+  [1]=
+  %string|unicode%(4) 2===
+}
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: class 'bar' does not have a method 'inexistent' in %s on line %d
+bool(false)


Property changes on: 

[PHP-CVS] svn: php/php-src/branches/PHP_5_3/ext/pdo/ pdo_stmt.c

2009-07-15 Thread Felipe Pena
felipe  Thu, 16 Jul 2009 00:59:34 +

URL: http://svn.php.net/viewvc?view=revisionrevision=284163

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c

Log:
- Removed trailing zeros on double to string conversion (noticed on #48924)

Modified: php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c
===
--- php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c 2009-07-16 00:56:35 UTC 
(rev 284162)
+++ php/php-src/branches/PHP_5_3/ext/pdo/pdo_stmt.c 2009-07-16 00:59:34 UTC 
(rev 284163)
@@ -317,7 +317,7 @@
if (PDO_PARAM_TYPE(param-param_type) == PDO_PARAM_STR  
param-max_value_len = 0  ! ZVAL_IS_NULL(param-parameter)) {
if (Z_TYPE_P(param-parameter) == IS_DOUBLE) {
char *p;
-   int len = spprintf(p, 0, %F, 
Z_DVAL_P(param-parameter));
+   int len = spprintf(p, 0, %.*H, (int) EG(precision), 
Z_DVAL_P(param-parameter));
ZVAL_STRINGL(param-parameter, p, len, 0);
} else {
convert_to_string(param-parameter);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php