From: Marcus Boerger Date: Mon, 20 Mar 2006 20:54:34 +0000 (+0000) Subject: - Added PDO_ATTR_DEFAULT_FETCH_MODE which controls the default fetch mode X-Git-Tag: RELEASE_1_3~349 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=56ed3211a634361fb24890d4337f6b1ad7dff96f;p=php - Added PDO_ATTR_DEFAULT_FETCH_MODE which controls the default fetch mode --- diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index d753d51540..a25a164f88 100755 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -723,6 +723,15 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D dbh->oracle_nulls = Z_LVAL_P(value); return SUCCESS; + case PDO_ATTR_DEFAULT_FETCH_MODE: + convert_to_long(value); + if (Z_LVAL_P(value) == PDO_FETCH_USE_DEFAULT) { + pdo_raise_impl_error(dbh, NULL, "HY000", "invalid fetch mode type" TSRMLS_CC); + return FAILURE; + } + dbh->default_fetch_type = Z_LVAL_P(value); + return SUCCESS; + case PDO_ATTR_STRINGIFY_FETCHES: convert_to_long(value); dbh->stringify = Z_LVAL_P(value) ? 1 : 0; @@ -869,6 +878,9 @@ static PHP_METHOD(PDO, getAttribute) add_next_index_zval(return_value, dbh->def_stmt_ctor_args); } return; + case PDO_ATTR_DEFAULT_FETCH_MODE: + RETURN_LONG(dbh->default_fetch_type); + } if (!dbh->methods->get_attribute) { @@ -1308,6 +1320,7 @@ void pdo_dbh_init(TSRMLS_D) 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_DEFAULT_FETCH_MODE",(long)PDO_ATTR_DEFAULT_FETCH_MODE); REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_SILENT", (long)PDO_ERRMODE_SILENT); REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_WARNING", (long)PDO_ERRMODE_WARNING); diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h index 514721069d..2e5d56d339 100755 --- a/ext/pdo/php_pdo_driver.h +++ b/ext/pdo/php_pdo_driver.h @@ -130,6 +130,7 @@ enum pdo_attribute_type { 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_DEFAULT_FETCH_MODE, /* Set the default fetch mode */ /* this defines the start of the range for driver specific options. * Drivers should define their own attribute constants beginning with this