wez Sun Apr 9 08:05:01 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/ext/pdo pdo_dbh.c pdo_stmt.c php_pdo_driver.h Log: Add "ATTR_EMULATE_PREPARES" general attribute to replace the custom attributes employed by mysql and postgres drivers. No functional change. http://cvs.php.net/viewcvs.cgi/php-src/ext/pdo/pdo_dbh.c?r1=1.82.2.29&r2=1.82.2.30&diff_format=u Index: php-src/ext/pdo/pdo_dbh.c diff -u php-src/ext/pdo/pdo_dbh.c:1.82.2.29 php-src/ext/pdo/pdo_dbh.c:1.82.2.30 --- php-src/ext/pdo/pdo_dbh.c:1.82.2.29 Thu Mar 23 19:01:46 2006 +++ php-src/ext/pdo/pdo_dbh.c Sun Apr 9 08:05:01 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_dbh.c,v 1.82.2.29 2006/03/23 19:01:46 tony2001 Exp $ */ +/* $Id: pdo_dbh.c,v 1.82.2.30 2006/04/09 08:05:01 wez Exp $ */ /* The PDO Database Handle Class */ @@ -1287,6 +1287,7 @@ REGISTER_PDO_CLASS_CONST_LONG("ATTR_DRIVER_NAME", (long)PDO_ATTR_DRIVER_NAME); REGISTER_PDO_CLASS_CONST_LONG("ATTR_STRINGIFY_FETCHES",(long)PDO_ATTR_STRINGIFY_FETCHES); REGISTER_PDO_CLASS_CONST_LONG("ATTR_MAX_COLUMN_LEN",(long)PDO_ATTR_MAX_COLUMN_LEN); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_EMULATE_PREPARES",(long)PDO_ATTR_EMULATE_PREPARES); REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_SILENT", (long)PDO_ERRMODE_SILENT); REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_WARNING", (long)PDO_ERRMODE_WARNING); http://cvs.php.net/viewcvs.cgi/php-src/ext/pdo/pdo_stmt.c?r1=1.118.2.36&r2=1.118.2.37&diff_format=u Index: php-src/ext/pdo/pdo_stmt.c diff -u php-src/ext/pdo/pdo_stmt.c:1.118.2.36 php-src/ext/pdo/pdo_stmt.c:1.118.2.37 --- php-src/ext/pdo/pdo_stmt.c:1.118.2.36 Tue Mar 28 20:19:44 2006 +++ php-src/ext/pdo/pdo_stmt.c Sun Apr 9 08:05:01 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_stmt.c,v 1.118.2.36 2006/03/28 20:19:44 tony2001 Exp $ */ +/* $Id: pdo_stmt.c,v 1.118.2.37 2006/04/09 08:05:01 wez Exp $ */ /* The PDO Statement Handle Class */ @@ -1633,6 +1633,17 @@ /* {{{ proto mixed PDOStatement::getAttribute(long attribute) Get an attribute */ + +static int generic_stmt_attr_get(pdo_stmt_t *stmt, zval *return_value, long attr) +{ + switch (attr) { + case PDO_ATTR_EMULATE_PREPARES: + RETVAL_BOOL(stmt->supports_placeholders == PDO_PLACEHOLDER_NONE); + return 1; + } + return 0; +} + static PHP_METHOD(PDOStatement, getAttribute) { long attr; @@ -1643,8 +1654,12 @@ } if (!stmt->methods->get_attribute) { - pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "This driver doesn't support getting attributes" TSRMLS_CC); - RETURN_FALSE; + if (!generic_stmt_attr_get(stmt, return_value, attr)) { + pdo_raise_impl_error(stmt->dbh, stmt, "IM001", + "This driver doesn't support getting attributes" TSRMLS_CC); + RETURN_FALSE; + } + return; } PDO_STMT_CLEAR_ERR(); @@ -1654,9 +1669,13 @@ RETURN_FALSE; case 0: - /* XXX: should do something better here */ - pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "driver doesn't support getting that attribute" TSRMLS_CC); - RETURN_FALSE; + if (!generic_stmt_attr_get(stmt, return_value, attr)) { + /* XXX: should do something better here */ + pdo_raise_impl_error(stmt->dbh, stmt, "IM001", + "driver doesn't support getting that attribute" TSRMLS_CC); + RETURN_FALSE; + } + return; default: return; http://cvs.php.net/viewcvs.cgi/php-src/ext/pdo/php_pdo_driver.h?r1=1.66.2.10&r2=1.66.2.11&diff_format=u Index: php-src/ext/pdo/php_pdo_driver.h diff -u php-src/ext/pdo/php_pdo_driver.h:1.66.2.10 php-src/ext/pdo/php_pdo_driver.h:1.66.2.11 --- php-src/ext/pdo/php_pdo_driver.h:1.66.2.10 Mon Mar 27 20:51:01 2006 +++ php-src/ext/pdo/php_pdo_driver.h Sun Apr 9 08:05:01 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pdo_driver.h,v 1.66.2.10 2006/03/27 20:51:01 wez Exp $ */ +/* $Id: php_pdo_driver.h,v 1.66.2.11 2006/04/09 08:05:01 wez Exp $ */ #ifndef PHP_PDO_DRIVER_H #define PHP_PDO_DRIVER_H @@ -44,7 +44,7 @@ # define FALSE 0 #endif -#define PDO_DRIVER_API 20060327 +#define PDO_DRIVER_API 20060409 enum pdo_param_type { PDO_PARAM_NULL, @@ -129,6 +129,7 @@ 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 */ PDO_ATTR_MAX_COLUMN_LEN, /* make database calculate maximum length of data found in a column */ + PDO_ATTR_EMULATE_PREPARES, /* use query emulation rather than native */ /* this defines the start of the range for driver specific options. * Drivers should define their own attribute constants beginning with this
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php