wez Fri Jul 8 00:13:01 2005 EDT
Modified files:
/php-src/ext/pdo pdo.c pdo_dbh.c pdo_stmt.c php_pdo_driver.h
/php-src/ext/pdo/tests pdo_test.inc
Log:
Add a PDO_ATTR_STRINGIFY_FETCHES attribute, which is used to convert integer
or
floating point values into strings during fetch. This is a compatibility hack
for drivers that return native types rather than string representations.
We use this flag in the test suite to persuade postgres tests to pass.
http://cvs.php.net/diff.php/php-src/ext/pdo/pdo.c?r1=1.53&r2=1.54&ty=u
Index: php-src/ext/pdo/pdo.c
diff -u php-src/ext/pdo/pdo.c:1.53 php-src/ext/pdo/pdo.c:1.54
--- php-src/ext/pdo/pdo.c:1.53 Thu Jul 7 13:08:01 2005
+++ php-src/ext/pdo/pdo.c Fri Jul 8 00:12:57 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo.c,v 1.53 2005/07/07 17:08:01 wez Exp $ */
+/* $Id: pdo.c,v 1.54 2005/07/08 04:12:57 wez Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -337,6 +337,7 @@
REGISTER_LONG_CONSTANT("PDO_ATTR_FETCH_TABLE_NAMES",
(long)PDO_ATTR_FETCH_TABLE_NAMES,
CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_FETCH_CATALOG_NAMES",
(long)PDO_ATTR_FETCH_CATALOG_NAMES,
CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ATTR_DRIVER_NAME",
(long)PDO_ATTR_DRIVER_NAME, CONST_CS|CONST_PERSISTENT);
+
REGISTER_LONG_CONSTANT("PDO_ATTR_STRINGIFY_FETCHES",(long)PDO_ATTR_STRINGIFY_FETCHES,
CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERRMODE_SILENT",
(long)PDO_ERRMODE_SILENT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PDO_ERRMODE_WARNING",
(long)PDO_ERRMODE_WARNING, CONST_CS|CONST_PERSISTENT);
http://cvs.php.net/diff.php/php-src/ext/pdo/pdo_dbh.c?r1=1.78&r2=1.79&ty=u
Index: php-src/ext/pdo/pdo_dbh.c
diff -u php-src/ext/pdo/pdo_dbh.c:1.78 php-src/ext/pdo/pdo_dbh.c:1.79
--- php-src/ext/pdo/pdo_dbh.c:1.78 Thu Jul 7 13:08:01 2005
+++ php-src/ext/pdo/pdo_dbh.c Fri Jul 8 00:12:58 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_dbh.c,v 1.78 2005/07/07 17:08:01 wez Exp $ */
+/* $Id: pdo_dbh.c,v 1.79 2005/07/08 04:12:58 wez Exp $ */
/* The PDO Database Handle Class */
@@ -693,6 +693,11 @@
convert_to_long(value);
dbh->oracle_nulls = Z_LVAL_P(value) ? 1 : 0;
RETURN_TRUE;
+
+ case PDO_ATTR_STRINGIFY_FETCHES:
+ convert_to_long(value);
+ dbh->stringify = Z_LVAL_P(value) ? 1 : 0;
+ RETURN_TRUE;
default:
;
http://cvs.php.net/diff.php/php-src/ext/pdo/pdo_stmt.c?r1=1.104&r2=1.105&ty=u
Index: php-src/ext/pdo/pdo_stmt.c
diff -u php-src/ext/pdo/pdo_stmt.c:1.104 php-src/ext/pdo/pdo_stmt.c:1.105
--- php-src/ext/pdo/pdo_stmt.c:1.104 Thu Jul 7 11:14:10 2005
+++ php-src/ext/pdo/pdo_stmt.c Fri Jul 8 00:12:58 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_stmt.c,v 1.104 2005/07/07 15:14:10 iliaa Exp $ */
+/* $Id: pdo_stmt.c,v 1.105 2005/07/08 04:12:58 wez Exp $ */
/* The PDO Statement Handle Class */
@@ -481,6 +481,15 @@
if (caller_frees && value) {
efree(value);
}
+
+ if (stmt->dbh->stringify) {
+ switch (Z_TYPE_P(dest)) {
+ case IS_LONG:
+ case IS_DOUBLE:
+ convert_to_string(dest);
+ break;
+ }
+ }
}
/* }}} */
http://cvs.php.net/diff.php/php-src/ext/pdo/php_pdo_driver.h?r1=1.60&r2=1.61&ty=u
Index: php-src/ext/pdo/php_pdo_driver.h
diff -u php-src/ext/pdo/php_pdo_driver.h:1.60
php-src/ext/pdo/php_pdo_driver.h:1.61
--- php-src/ext/pdo/php_pdo_driver.h:1.60 Thu Jul 7 12:24:51 2005
+++ php-src/ext/pdo/php_pdo_driver.h Fri Jul 8 00:12:58 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pdo_driver.h,v 1.60 2005/07/07 16:24:51 wez Exp $ */
+/* $Id: php_pdo_driver.h,v 1.61 2005/07/08 04:12:58 wez Exp $ */
#ifndef PHP_PDO_DRIVER_H
#define PHP_PDO_DRIVER_H
@@ -44,7 +44,7 @@
# define FALSE 0
#endif
-#define PDO_DRIVER_API 20050707
+#define PDO_DRIVER_API 20050708
enum pdo_param_type {
PDO_PARAM_NULL,
@@ -127,6 +127,7 @@
PDO_ATTR_FETCH_TABLE_NAMES, /* include table names in the column names,
where available */
PDO_ATTR_FETCH_CATALOG_NAMES, /* include the catalog/db name names in
the column names, where available */
PDO_ATTR_DRIVER_NAME, /* name of the driver (as used in the
constructor) */
+ PDO_ATTR_STRINGIFY_FETCHES, /* converts integer/float types to
strings during fetch */
/* this defines the start of the range for driver specific options.
* Drivers should define their own attribute constants beginning with
this
@@ -432,9 +433,12 @@
/* when set, convert empty strings to NULL */
unsigned oracle_nulls:1;
+ /* when set, convert int/floats to strings */
+ unsigned stringify:1;
+
/* the sum of the number of bits here and the bit fields preceeding
should
* equal 32 */
- unsigned _reserved_flags:23;
+ unsigned _reserved_flags:22;
/* data source string used to open this handle */
const char *data_source;
http://cvs.php.net/diff.php/php-src/ext/pdo/tests/pdo_test.inc?r1=1.5&r2=1.6&ty=u
Index: php-src/ext/pdo/tests/pdo_test.inc
diff -u php-src/ext/pdo/tests/pdo_test.inc:1.5
php-src/ext/pdo/tests/pdo_test.inc:1.6
--- php-src/ext/pdo/tests/pdo_test.inc:1.5 Thu Jul 7 11:32:32 2005
+++ php-src/ext/pdo/tests/pdo_test.inc Fri Jul 8 00:13:00 2005
@@ -29,6 +29,7 @@
$db->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_WARNING);
$db->setAttribute(PDO_ATTR_CASE, PDO_CASE_LOWER);
+ $db->setAttribute(PDO_ATTR_STRINGIFY_FETCHES, true);
return $db;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php