From bfe844e41e159460867826ce8559c670c2f24ec9 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Tue, 20 Sep 2005 00:35:21 +0000 Subject: [PATCH] MFH: Make PDO use class constants --- NEWS | 1 + ext/pdo/pdo.c | 83 ------------------------- ext/pdo/pdo_dbh.c | 84 ++++++++++++++++++++++++++ ext/pdo/php_pdo.h | 12 ++++ ext/pdo/tests/pdo_001.phpt | 4 +- ext/pdo/tests/pdo_002.phpt | 4 +- ext/pdo/tests/pdo_003.phpt | 4 +- ext/pdo/tests/pdo_004.phpt | 4 +- ext/pdo/tests/pdo_005.phpt | 8 +-- ext/pdo/tests/pdo_006.phpt | 6 +- ext/pdo/tests/pdo_007.phpt | 6 +- ext/pdo/tests/pdo_008.phpt | 4 +- ext/pdo/tests/pdo_009.phpt | 6 +- ext/pdo/tests/pdo_010.phpt | 6 +- ext/pdo/tests/pdo_011.phpt | 14 ++--- ext/pdo/tests/pdo_012.phpt | 8 +-- ext/pdo/tests/pdo_013.phpt | 6 +- ext/pdo/tests/pdo_014.phpt | 6 +- ext/pdo/tests/pdo_015.phpt | 18 +++--- ext/pdo/tests/pdo_016.phpt | 16 ++--- ext/pdo/tests/pdo_016a.phpt | 16 ++--- ext/pdo/tests/pdo_017.phpt | 4 +- ext/pdo/tests/pdo_018.phpt | 14 ++--- ext/pdo/tests/pdo_019.phpt | 4 +- ext/pdo/tests/pdo_023.phpt | 4 +- ext/pdo/tests/pdo_025.phpt | 6 +- ext/pdo/tests/pdo_026.phpt | 4 +- ext/pdo/tests/pdo_027.phpt | 4 +- ext/pdo/tests/pdo_028.phpt | 2 +- ext/pdo/tests/pdo_test.inc | 6 +- ext/pdo_mysql/pdo_mysql.c | 2 +- ext/pdo_mysql/tests/pecl_bug_5200.phpt | 2 +- ext/pdo_oci/tests/bug_33707.phpt | 2 +- ext/pdo_pgsql/pdo_pgsql.c | 2 +- ext/pdo_pgsql/tests/bug_33876.phpt | 28 ++++----- 35 files changed, 207 insertions(+), 193 deletions(-) diff --git a/NEWS b/NEWS index 05b66915984..c34a8c66d06 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? Aug 2005, PHP 5.1 Release Candidate 2 +- Made PDO use class constants. (Ilia) - Changed "instanceof" and "catch" operators, is_a() and is_subclass_of() functions to not call __autoload(). (Dmitry) - Added support for class constants and static members for internal classes. diff --git a/ext/pdo/pdo.c b/ext/pdo/pdo.c index a58f3fd47e2..76f1139b7f5 100755 --- a/ext/pdo/pdo.c +++ b/ext/pdo/pdo.c @@ -277,89 +277,6 @@ PHP_MINIT_FUNCTION(pdo) le_ppdo = zend_register_list_destructors_ex(NULL, php_pdo_pdbh_dtor, "PDO persistent database", module_number); - REGISTER_LONG_CONSTANT("PDO_PARAM_BOOL", (long)PDO_PARAM_BOOL, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_PARAM_NULL", (long)PDO_PARAM_NULL, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_PARAM_INT", (long)PDO_PARAM_INT, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_PARAM_STR", (long)PDO_PARAM_STR, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_PARAM_LOB", (long)PDO_PARAM_LOB, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_PARAM_STMT", (long)PDO_PARAM_STMT, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_PARAM_INPUT_OUTPUT", (long)PDO_PARAM_INPUT_OUTPUT, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("PDO_FETCH_LAZY", (long)PDO_FETCH_LAZY, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_ASSOC",(long)PDO_FETCH_ASSOC, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_NUM", (long)PDO_FETCH_NUM, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_BOTH", (long)PDO_FETCH_BOTH, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_OBJ", (long)PDO_FETCH_OBJ, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_BOUND",(long)PDO_FETCH_BOUND, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_COLUMN",(long)PDO_FETCH_COLUMN, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_CLASS",(long)PDO_FETCH_CLASS, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_INTO", (long)PDO_FETCH_INTO, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_FUNC", (long)PDO_FETCH_FUNC, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_GROUP",(long)PDO_FETCH_GROUP, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_UNIQUE",(long)PDO_FETCH_UNIQUE, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_CLASSTYPE",(long)PDO_FETCH_CLASSTYPE, CONST_CS|CONST_PERSISTENT); -#if PHP_MAJOR_VERSION > 5 || PHP_MINOR_VERSION >= 1 - REGISTER_LONG_CONSTANT("PDO_FETCH_SERIALIZE",(long)PDO_FETCH_SERIALIZE, CONST_CS|CONST_PERSISTENT); -#endif - REGISTER_LONG_CONSTANT("PDO_FETCH_NAMED",(long)PDO_FETCH_NAMED, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("PDO_ATTR_AUTOCOMMIT", (long)PDO_ATTR_AUTOCOMMIT, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ATTR_PREFETCH", (long)PDO_ATTR_PREFETCH, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ATTR_TIMEOUT", (long)PDO_ATTR_TIMEOUT, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ATTR_ERRMODE", (long)PDO_ATTR_ERRMODE, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ATTR_SERVER_VERSION", (long)PDO_ATTR_SERVER_VERSION, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ATTR_CLIENT_VERSION", (long)PDO_ATTR_CLIENT_VERSION, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ATTR_SERVER_INFO", (long)PDO_ATTR_SERVER_INFO, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ATTR_CONNECTION_STATUS", (long)PDO_ATTR_CONNECTION_STATUS, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ATTR_CASE", (long)PDO_ATTR_CASE, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ATTR_CURSOR_NAME", (long)PDO_ATTR_CURSOR_NAME, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ATTR_CURSOR", (long)PDO_ATTR_CURSOR, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ATTR_ORACLE_NULLS", (long)PDO_ATTR_ORACLE_NULLS, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ATTR_PERSISTENT", (long)PDO_ATTR_PERSISTENT, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ATTR_STATEMENT_CLASS", (long)PDO_ATTR_STATEMENT_CLASS, CONST_CS|CONST_PERSISTENT); - 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_ATTR_MAX_COLUMN_LEN",(long)PDO_ATTR_MAX_COLUMN_LEN, 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); - REGISTER_LONG_CONSTANT("PDO_ERRMODE_EXCEPTION", (long)PDO_ERRMODE_EXCEPTION, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("PDO_CASE_NATURAL", (long)PDO_CASE_NATURAL, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_CASE_LOWER", (long)PDO_CASE_LOWER, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_CASE_UPPER", (long)PDO_CASE_UPPER, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("PDO_NULL_NATURAL", (long)PDO_NULL_NATURAL, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_NULL_EMPTY_STRING", (long)PDO_NULL_EMPTY_STRING, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_NULL_TO_STRING", (long)PDO_NULL_TO_STRING, CONST_CS|CONST_PERSISTENT); - - REGISTER_STRING_CONSTANT("PDO_ERR_NONE", PDO_ERR_NONE, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("PDO_FETCH_ORI_NEXT", (long)PDO_FETCH_ORI_NEXT, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_ORI_PRIOR", (long)PDO_FETCH_ORI_PRIOR, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_ORI_FIRST", (long)PDO_FETCH_ORI_FIRST, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_ORI_LAST", (long)PDO_FETCH_ORI_LAST, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_ORI_ABS", (long)PDO_FETCH_ORI_ABS, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_FETCH_ORI_REL", (long)PDO_FETCH_ORI_REL, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("PDO_CURSOR_FWDONLY", (long)PDO_CURSOR_FWDONLY,CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_CURSOR_SCROLL", (long)PDO_CURSOR_SCROLL,CONST_CS|CONST_PERSISTENT); - -#if 0 - REGISTER_LONG_CONSTANT("PDO_ERR_CANT_MAP", (long)PDO_ERR_CANT_MAP, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ERR_SYNTAX", (long)PDO_ERR_SYNTAX, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ERR_CONSTRAINT", (long)PDO_ERR_CONSTRAINT, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ERR_NOT_FOUND", (long)PDO_ERR_NOT_FOUND, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ERR_ALREADY_EXISTS", (long)PDO_ERR_ALREADY_EXISTS, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ERR_NOT_IMPLEMENTED", (long)PDO_ERR_NOT_IMPLEMENTED, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ERR_MISMATCH", (long)PDO_ERR_MISMATCH, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ERR_TRUNCATED", (long)PDO_ERR_TRUNCATED, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ERR_DISCONNECTED", (long)PDO_ERR_DISCONNECTED, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("PDO_ERR_NO_PERM", (long)PDO_ERR_NO_PERM, CONST_CS|CONST_PERSISTENT); -#endif - INIT_CLASS_ENTRY(ce, "PDOException", NULL); #if can_handle_soft_dependency_on_SPL && defined(HAVE_SPL) && ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1)) pdo_exception_ce = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException, NULL TSRMLS_CC); diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index dae5691ff6a..2f2c80ddb69 100755 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -1137,6 +1137,90 @@ void pdo_dbh_init(TSRMLS_D) memcpy(&pdo_dbh_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); pdo_dbh_object_handlers.get_method = dbh_method_get; pdo_dbh_object_handlers.compare_objects = dbh_compare; + + REGISTER_PDO_CLASS_CONST_LONG("PARAM_BOOL", (long)PDO_PARAM_BOOL); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_NULL", (long)PDO_PARAM_NULL); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_INT", (long)PDO_PARAM_INT); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_STR", (long)PDO_PARAM_STR); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_LOB", (long)PDO_PARAM_LOB); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_STMT", (long)PDO_PARAM_STMT); + REGISTER_PDO_CLASS_CONST_LONG("PARAM_INPUT_OUTPUT", (long)PDO_PARAM_INPUT_OUTPUT); + + REGISTER_PDO_CLASS_CONST_LONG("FETCH_LAZY", (long)PDO_FETCH_LAZY); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_ASSOC",(long)PDO_FETCH_ASSOC); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_NUM", (long)PDO_FETCH_NUM); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_BOTH", (long)PDO_FETCH_BOTH); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_OBJ", (long)PDO_FETCH_OBJ); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_BOUND",(long)PDO_FETCH_BOUND); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_COLUMN",(long)PDO_FETCH_COLUMN); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_CLASS",(long)PDO_FETCH_CLASS); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_INTO", (long)PDO_FETCH_INTO); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_FUNC", (long)PDO_FETCH_FUNC); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_GROUP",(long)PDO_FETCH_GROUP); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_UNIQUE",(long)PDO_FETCH_UNIQUE); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_CLASSTYPE",(long)PDO_FETCH_CLASSTYPE); +#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_NAMED",(long)PDO_FETCH_NAMED); + + REGISTER_PDO_CLASS_CONST_LONG("ATTR_AUTOCOMMIT", (long)PDO_ATTR_AUTOCOMMIT); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_PREFETCH", (long)PDO_ATTR_PREFETCH); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_TIMEOUT", (long)PDO_ATTR_TIMEOUT); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_ERRMODE", (long)PDO_ATTR_ERRMODE); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_SERVER_VERSION", (long)PDO_ATTR_SERVER_VERSION); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_CLIENT_VERSION", (long)PDO_ATTR_CLIENT_VERSION); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_SERVER_INFO", (long)PDO_ATTR_SERVER_INFO); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_CONNECTION_STATUS", (long)PDO_ATTR_CONNECTION_STATUS); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_CASE", (long)PDO_ATTR_CASE); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_CURSOR_NAME", (long)PDO_ATTR_CURSOR_NAME); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_CURSOR", (long)PDO_ATTR_CURSOR); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_ORACLE_NULLS", (long)PDO_ATTR_ORACLE_NULLS); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_PERSISTENT", (long)PDO_ATTR_PERSISTENT); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_STATEMENT_CLASS", (long)PDO_ATTR_STATEMENT_CLASS); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_FETCH_TABLE_NAMES", (long)PDO_ATTR_FETCH_TABLE_NAMES); + REGISTER_PDO_CLASS_CONST_LONG("ATTR_FETCH_CATALOG_NAMES", (long)PDO_ATTR_FETCH_CATALOG_NAMES); + 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("ERRMODE_SILENT", (long)PDO_ERRMODE_SILENT); + REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_WARNING", (long)PDO_ERRMODE_WARNING); + REGISTER_PDO_CLASS_CONST_LONG("ERRMODE_EXCEPTION", (long)PDO_ERRMODE_EXCEPTION); + + REGISTER_PDO_CLASS_CONST_LONG("CASE_NATURAL", (long)PDO_CASE_NATURAL); + REGISTER_PDO_CLASS_CONST_LONG("CASE_LOWER", (long)PDO_CASE_LOWER); + REGISTER_PDO_CLASS_CONST_LONG("CASE_UPPER", (long)PDO_CASE_UPPER); + + REGISTER_PDO_CLASS_CONST_LONG("NULL_NATURAL", (long)PDO_NULL_NATURAL); + REGISTER_PDO_CLASS_CONST_LONG("NULL_EMPTY_STRING", (long)PDO_NULL_EMPTY_STRING); + REGISTER_PDO_CLASS_CONST_LONG("NULL_TO_STRING", (long)PDO_NULL_TO_STRING); + + REGISTER_PDO_CLASS_CONST_STRING("ERR_NONE", PDO_ERR_NONE); + + REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_NEXT", (long)PDO_FETCH_ORI_NEXT); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_PRIOR", (long)PDO_FETCH_ORI_PRIOR); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_FIRST", (long)PDO_FETCH_ORI_FIRST); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_LAST", (long)PDO_FETCH_ORI_LAST); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_ABS", (long)PDO_FETCH_ORI_ABS); + REGISTER_PDO_CLASS_CONST_LONG("FETCH_ORI_REL", (long)PDO_FETCH_ORI_REL); + + REGISTER_PDO_CLASS_CONST_LONG("CURSOR_FWDONLY", (long)PDO_CURSOR_FWDONLY); + REGISTER_PDO_CLASS_CONST_LONG("CURSOR_SCROLL", (long)PDO_CURSOR_SCROLL); + +#if 0 + REGISTER_PDO_CLASS_CONST_LONG("ERR_CANT_MAP", (long)PDO_ERR_CANT_MAP); + REGISTER_PDO_CLASS_CONST_LONG("ERR_SYNTAX", (long)PDO_ERR_SYNTAX); + REGISTER_PDO_CLASS_CONST_LONG("ERR_CONSTRAINT", (long)PDO_ERR_CONSTRAINT); + REGISTER_PDO_CLASS_CONST_LONG("ERR_NOT_FOUND", (long)PDO_ERR_NOT_FOUND); + REGISTER_PDO_CLASS_CONST_LONG("ERR_ALREADY_EXISTS", (long)PDO_ERR_ALREADY_EXISTS); + REGISTER_PDO_CLASS_CONST_LONG("ERR_NOT_IMPLEMENTED", (long)PDO_ERR_NOT_IMPLEMENTED); + REGISTER_PDO_CLASS_CONST_LONG("ERR_MISMATCH", (long)PDO_ERR_MISMATCH); + REGISTER_PDO_CLASS_CONST_LONG("ERR_TRUNCATED", (long)PDO_ERR_TRUNCATED); + REGISTER_PDO_CLASS_CONST_LONG("ERR_DISCONNECTED", (long)PDO_ERR_DISCONNECTED); + REGISTER_PDO_CLASS_CONST_LONG("ERR_NO_PERM", (long)PDO_ERR_NO_PERM); +#endif + } static void dbh_free(pdo_dbh_t *dbh TSRMLS_DC) diff --git a/ext/pdo/php_pdo.h b/ext/pdo/php_pdo.h index c9fbb5606c7..ba63cbfb97b 100755 --- a/ext/pdo/php_pdo.h +++ b/ext/pdo/php_pdo.h @@ -58,6 +58,18 @@ ZEND_END_MODULE_GLOBALS(pdo) # define PDOG(v) (pdo_globals.v) #endif +#define REGISTER_PDO_CLASS_CONST_LONG(const_name, value) \ + zend_declare_class_constant_long(pdo_dbh_ce, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); + +#define REGISTER_PDO_CONST_LONG(const_name, value) { \ + zend_class_entry **pce; \ + if (zend_hash_find(CG(class_table), "pdo", sizeof("pdo"), (void **) &pce) != FAILURE) \ + zend_declare_class_constant_long(*pce, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); \ +} \ + +#define REGISTER_PDO_CLASS_CONST_STRING(const_name, value) \ + zend_declare_class_constant_stringl(pdo_dbh_ce, const_name, sizeof(const_name)-1, value, sizeof(value)-1 TSRMLS_CC); + #endif /* PHP_PDO_H */ diff --git a/ext/pdo/tests/pdo_001.phpt b/ext/pdo/tests/pdo_001.phpt index 6740411f77a..e90d8ff1627 100644 --- a/ext/pdo/tests/pdo_001.phpt +++ b/ext/pdo/tests/pdo_001.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_ASSOC +PDO Common: PDO::FETCH_ASSOC --SKIPIF-- exec("INSERT INTO test VALUES(3, 'C')"); $stmt = $db->prepare('SELECT * from test'); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_ASSOC)); +var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); ?> --EXPECT-- array(3) { diff --git a/ext/pdo/tests/pdo_002.phpt b/ext/pdo/tests/pdo_002.phpt index 9de520ba70b..4c4363ba4a1 100644 --- a/ext/pdo/tests/pdo_002.phpt +++ b/ext/pdo/tests/pdo_002.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_NUM +PDO Common: PDO::FETCH_NUM --SKIPIF-- exec("INSERT INTO test VALUES(3, 'C')"); $stmt = $db->prepare('SELECT * from test'); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_NUM)); +var_dump($stmt->fetchAll(PDO::FETCH_NUM)); ?> --EXPECT-- array(3) { diff --git a/ext/pdo/tests/pdo_003.phpt b/ext/pdo/tests/pdo_003.phpt index 255eb124cf0..b4d86dece1d 100644 --- a/ext/pdo/tests/pdo_003.phpt +++ b/ext/pdo/tests/pdo_003.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_BOTH +PDO Common: PDO::FETCH_BOTH --SKIPIF-- exec("INSERT INTO test VALUES(3, 'C')"); $stmt = $db->prepare('SELECT * from test'); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_BOTH)); +var_dump($stmt->fetchAll(PDO::FETCH_BOTH)); ?> --EXPECT-- array(3) { diff --git a/ext/pdo/tests/pdo_004.phpt b/ext/pdo/tests/pdo_004.phpt index 1f3f0f980ed..ab5af41e82d 100644 --- a/ext/pdo/tests/pdo_004.phpt +++ b/ext/pdo/tests/pdo_004.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_OBJ +PDO Common: PDO::FETCH_OBJ --SKIPIF-- exec("INSERT INTO test VALUES(3, 'C')"); $stmt = $db->prepare('SELECT * from test'); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_OBJ)); +var_dump($stmt->fetchAll(PDO::FETCH_OBJ)); ?> --EXPECTF-- array(3) { diff --git a/ext/pdo/tests/pdo_005.phpt b/ext/pdo/tests/pdo_005.phpt index 9e37665c1e6..3c107a0fa00 100644 --- a/ext/pdo/tests/pdo_005.phpt +++ b/ext/pdo/tests/pdo_005.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_CLASS +PDO Common: PDO::FETCH_CLASS --SKIPIF-- execute(); -var_dump($stmt->fetchAll(PDO_FETCH_CLASS)); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS)); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_CLASS, 'TestBase')); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS, 'TestBase')); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_CLASS, 'TestDerived', array(0))); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS, 'TestDerived', array(0))); ?> --EXPECTF-- diff --git a/ext/pdo/tests/pdo_006.phpt b/ext/pdo/tests/pdo_006.phpt index 90dbe0ba882..c8b92a5a8f6 100644 --- a/ext/pdo/tests/pdo_006.phpt +++ b/ext/pdo/tests/pdo_006.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_GROUP +PDO Common: PDO::FETCH_GROUP --SKIPIF-- exec("INSERT INTO test VALUES(3, 'C')"); $stmt = $db->prepare('SELECT val, id from test'); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_NUM|PDO_FETCH_GROUP)); +var_dump($stmt->fetchAll(PDO::FETCH_NUM|PDO::FETCH_GROUP)); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_ASSOC|PDO_FETCH_GROUP)); +var_dump($stmt->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_GROUP)); ?> --EXPECT-- diff --git a/ext/pdo/tests/pdo_007.phpt b/ext/pdo/tests/pdo_007.phpt index 49df24061dc..89794a1d896 100644 --- a/ext/pdo/tests/pdo_007.phpt +++ b/ext/pdo/tests/pdo_007.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_UNIQUE +PDO Common: PDO::FETCH_UNIQUE --SKIPIF-- exec("INSERT INTO test VALUES('C', 'C')"); $stmt = $db->prepare('SELECT id, val from test'); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_NUM|PDO_FETCH_UNIQUE)); +var_dump($stmt->fetchAll(PDO::FETCH_NUM|PDO::FETCH_UNIQUE)); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_ASSOC|PDO_FETCH_UNIQUE)); +var_dump($stmt->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE)); ?> --EXPECT-- diff --git a/ext/pdo/tests/pdo_008.phpt b/ext/pdo/tests/pdo_008.phpt index 594ccdab3d1..628904db2ff 100644 --- a/ext/pdo/tests/pdo_008.phpt +++ b/ext/pdo/tests/pdo_008.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_UNIQUE conflict +PDO Common: PDO::FETCH_UNIQUE conflict --SKIPIF-- exec("INSERT INTO test VALUES('C', 'C')"); $stmt = $db->prepare('SELECT val, id from test'); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_NUM|PDO_FETCH_UNIQUE)); +var_dump($stmt->fetchAll(PDO::FETCH_NUM|PDO::FETCH_UNIQUE)); ?> --EXPECT-- diff --git a/ext/pdo/tests/pdo_009.phpt b/ext/pdo/tests/pdo_009.phpt index b5527aba39e..48d9b573969 100644 --- a/ext/pdo/tests/pdo_009.phpt +++ b/ext/pdo/tests/pdo_009.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_CLASSTYPE +PDO Common: PDO::FETCH_CLASSTYPE --SKIPIF-- execute(); -var_dump($stmt->fetchAll(PDO_FETCH_NUM)); +var_dump($stmt->fetchAll(PDO::FETCH_NUM)); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_CLASS|PDO_FETCH_CLASSTYPE, 'Test3')); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE, 'Test3')); ?> --EXPECTF-- diff --git a/ext/pdo/tests/pdo_010.phpt b/ext/pdo/tests/pdo_010.phpt index 6de31d1ea12..8b51238ab44 100644 --- a/ext/pdo/tests/pdo_010.phpt +++ b/ext/pdo/tests/pdo_010.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_CLASSTYPE and GROUP/UNIQUE +PDO Common: PDO::FETCH_CLASSTYPE and GROUP/UNIQUE --SKIPIF-- execute(); -var_dump($stmt->fetchAll(PDO_FETCH_CLASS|PDO_FETCH_CLASSTYPE|PDO_FETCH_GROUP, 'Test3')); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_GROUP, 'Test3')); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_CLASS|PDO_FETCH_CLASSTYPE|PDO_FETCH_UNIQUE, 'Test3')); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_UNIQUE, 'Test3')); ?> --EXPECTF-- diff --git a/ext/pdo/tests/pdo_011.phpt b/ext/pdo/tests/pdo_011.phpt index 38ae8ff62af..40e478455be 100644 --- a/ext/pdo/tests/pdo_011.phpt +++ b/ext/pdo/tests/pdo_011.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_FUNC and statement overloading +PDO Common: PDO::FETCH_FUNC and statement overloading --SKIPIF-- prepare('SELECT grp, id FROM test'); $select2 = $db->prepare('SELECT id, val FROM test'); -$derived = $db->prepare('SELECT id, val FROM test', array(PDO_ATTR_STATEMENT_CLASS=>array('DerivedStatement', array('Overloaded', $db)))); +$derived = $db->prepare('SELECT id, val FROM test', array(PDO::ATTR_STATEMENT_CLASS=>array('DerivedStatement', array('Overloaded', $db)))); class Test1 { @@ -62,20 +62,20 @@ function test($id,$val='N/A') $f = new Test1(0,0); $select1->execute(); -var_dump($select1->fetchAll(PDO_FETCH_FUNC|PDO_FETCH_GROUP, 'test')); +var_dump($select1->fetchAll(PDO::FETCH_FUNC|PDO::FETCH_GROUP, 'test')); $select2->execute(); -var_dump($select2->fetchAll(PDO_FETCH_FUNC, 'test')); +var_dump($select2->fetchAll(PDO::FETCH_FUNC, 'test')); $select2->execute(); -var_dump($select2->fetchAll(PDO_FETCH_FUNC, array('Test1','factory'))); +var_dump($select2->fetchAll(PDO::FETCH_FUNC, array('Test1','factory'))); $select2->execute(); -var_dump($select2->fetchAll(PDO_FETCH_FUNC, array($f, 'factory'))); +var_dump($select2->fetchAll(PDO::FETCH_FUNC, array($f, 'factory'))); var_dump(get_class($derived)); $derived->execute(); -var_dump($derived->fetchAll(PDO_FETCH_FUNC, array($derived, 'retrieve'))); +var_dump($derived->fetchAll(PDO::FETCH_FUNC, array($derived, 'retrieve'))); ?> --EXPECTF-- diff --git a/ext/pdo/tests/pdo_012.phpt b/ext/pdo/tests/pdo_012.phpt index 77a625c3c4f..fe904dc146e 100644 --- a/ext/pdo/tests/pdo_012.phpt +++ b/ext/pdo/tests/pdo_012.phpt @@ -19,7 +19,7 @@ $db->exec('INSERT INTO test VALUES(2, \'B\', \'Group2\')'); $SELECT = 'SELECT val, grp FROM test'; -$stmt = $db->query($SELECT, PDO_FETCH_NUM); +$stmt = $db->query($SELECT, PDO::FETCH_NUM); var_dump($stmt->fetchAll()); class Test @@ -32,13 +32,13 @@ class Test unset($stmt); -$stmt = $db->query($SELECT, PDO_FETCH_CLASS, 'Test'); +$stmt = $db->query($SELECT, PDO::FETCH_CLASS, 'Test'); var_dump($stmt->fetchAll()); unset($stmt); -$stmt = $db->query($SELECT, PDO_FETCH_NUM); -$stmt->setFetchMode(PDO_FETCH_CLASS, 'Test', array('Changed')); +$stmt = $db->query($SELECT, PDO::FETCH_NUM); +$stmt->setFetchMode(PDO::FETCH_CLASS, 'Test', array('Changed')); var_dump($stmt->fetchAll()); ?> diff --git a/ext/pdo/tests/pdo_013.phpt b/ext/pdo/tests/pdo_013.phpt index 09296063362..6ce1fa0e136 100644 --- a/ext/pdo/tests/pdo_013.phpt +++ b/ext/pdo/tests/pdo_013.phpt @@ -22,7 +22,7 @@ $SELECT = 'SELECT val, grp FROM test'; $stmt = $db->prepare($SELECT); $stmt->execute(); -$stmt->setFetchMode(PDO_FETCH_NUM); +$stmt->setFetchMode(PDO::FETCH_NUM); foreach ($stmt as $data) { var_dump($data); @@ -38,14 +38,14 @@ class Test unset($stmt); -foreach ($db->query($SELECT, PDO_FETCH_CLASS, 'Test') as $data) +foreach ($db->query($SELECT, PDO::FETCH_CLASS, 'Test') as $data) { var_dump($data); } unset($stmt); -$stmt = $db->query($SELECT, PDO_FETCH_CLASS, 'Test', array('WOW')); +$stmt = $db->query($SELECT, PDO::FETCH_CLASS, 'Test', array('WOW')); foreach($stmt as $data) { diff --git a/ext/pdo/tests/pdo_014.phpt b/ext/pdo/tests/pdo_014.phpt index 1d21cb4a00d..2f18366f48b 100644 --- a/ext/pdo/tests/pdo_014.phpt +++ b/ext/pdo/tests/pdo_014.phpt @@ -28,7 +28,7 @@ class Test } } -$stmt = $db->query($SELECT, PDO_FETCH_CLASS, 'Test', array('WOW')); +$stmt = $db->query($SELECT, PDO::FETCH_CLASS, 'Test', array('WOW')); $it = new IteratorIterator($stmt); /* check if we can convert that thing */ @@ -48,7 +48,7 @@ class PDOStatementAggregate extends PDOStatement implements IteratorAggregate private function __construct() { echo __METHOD__ . "\n"; - $this->setFetchMode(PDO_FETCH_NUM); + $this->setFetchMode(PDO::FETCH_NUM); /* default fetch mode is BOTH, so we see if the ctor can overwrite that */ } @@ -60,7 +60,7 @@ class PDOStatementAggregate extends PDOStatement implements IteratorAggregate } } -$stmt = $db->prepare($SELECT, array(PDO_ATTR_STATEMENT_CLASS=>array('PDOStatementAggregate'))); +$stmt = $db->prepare($SELECT, array(PDO::ATTR_STATEMENT_CLASS=>array('PDOStatementAggregate'))); foreach($stmt as $data) { diff --git a/ext/pdo/tests/pdo_015.phpt b/ext/pdo/tests/pdo_015.phpt index 66424060bf3..6e90fdcb976 100644 --- a/ext/pdo/tests/pdo_015.phpt +++ b/ext/pdo/tests/pdo_015.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_COLUMN +PDO Common: PDO::FETCH_COLUMN --SKIPIF-- prepare('SELECT id, val, val2 FROM test'); $select2 = $db->prepare('SELECT val, val2 FROM test'); $select1->execute(); -var_dump($select1->fetchAll(PDO_FETCH_COLUMN)); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN)); $select1->execute(); -var_dump($select1->fetchAll(PDO_FETCH_COLUMN, 2)); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN, 2)); $select1->execute(); -var_dump($select1->fetchAll(PDO_FETCH_COLUMN|PDO_FETCH_GROUP)); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_GROUP)); $select1->execute(); -var_dump($select1->fetchAll(PDO_FETCH_COLUMN|PDO_FETCH_UNIQUE)); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE)); $select1->execute(); -var_dump($select1->fetchAll(PDO_FETCH_COLUMN|PDO_FETCH_UNIQUE, 0)); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE, 0)); $select1->execute(); -var_dump($select1->fetchAll(PDO_FETCH_COLUMN|PDO_FETCH_UNIQUE, 1)); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE, 1)); $select1->execute(); -var_dump($select1->fetchAll(PDO_FETCH_COLUMN|PDO_FETCH_UNIQUE, 2)); +var_dump($select1->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE, 2)); $select2->execute(); -var_dump($select2->fetchAll(PDO_FETCH_COLUMN|PDO_FETCH_GROUP)); +var_dump($select2->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_GROUP)); ?> --EXPECT-- diff --git a/ext/pdo/tests/pdo_016.phpt b/ext/pdo/tests/pdo_016.phpt index e2faf05c46d..fa6715f06bc 100644 --- a/ext/pdo/tests/pdo_016.phpt +++ b/ext/pdo/tests/pdo_016.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_BOUND +PDO Common: PDO::FETCH_BOUND --SKIPIF-- fetchColumn()); $stmt1 = null; $stmt2->execute(); -$cont = $stmt2->fetchAll(PDO_FETCH_COLUMN|PDO_FETCH_UNIQUE); +$cont = $stmt2->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE); var_dump($cont); echo "===WHILE===\n"; @@ -35,7 +35,7 @@ $stmt2->bindColumn('idx', $idx); $stmt2->bindColumn('txt', $txt); $stmt2->execute(); -while($stmt2->fetch(PDO_FETCH_BOUND)) { +while($stmt2->fetch(PDO::FETCH_BOUND)) { var_dump(array($idx=>$txt)); } @@ -57,7 +57,7 @@ foreach($cont as $idx => $txt) * after execute() has been called at least once */ $stmt3->bindColumn('txt', $col1); } - var_dump($stmt3->fetch(PDO_FETCH_BOUND)); + var_dump($stmt3->fetch(PDO::FETCH_BOUND)); $stmt3->closeCursor(); var_dump($stmt4->execute()); @@ -66,7 +66,7 @@ foreach($cont as $idx => $txt) * after execute() has been called at least once */ $stmt4->bindColumn('idx', $col2); } - var_dump($stmt4->fetch(PDO_FETCH_BOUND)); + var_dump($stmt4->fetch(PDO::FETCH_BOUND)); $stmt4->closeCursor(); var_dump(array($col2=>$col1)); } @@ -79,11 +79,11 @@ foreach($cont as $idx => $txt) { var_dump(array($idx=>$txt)); var_dump($stmt3->execute()); - var_dump($stmt3->fetch(PDO_FETCH_BOUND)); + var_dump($stmt3->fetch(PDO::FETCH_BOUND)); $stmt3->closeCursor(); var_dump($col1); var_dump($stmt4->execute()); - var_dump($stmt4->fetch(PDO_FETCH_BOUND)); + var_dump($stmt4->fetch(PDO::FETCH_BOUND)); $stmt4->closeCursor(); var_dump($col1); } @@ -94,7 +94,7 @@ $stmt2->bindColumn('idx', $col1); $stmt2->bindColumn('txt', $col1); $stmt2->execute(); -while($stmt2->fetch(PDO_FETCH_BOUND)) +while($stmt2->fetch(PDO::FETCH_BOUND)) { var_dump($col1); } diff --git a/ext/pdo/tests/pdo_016a.phpt b/ext/pdo/tests/pdo_016a.phpt index 34d626aed89..2ec1f229032 100755 --- a/ext/pdo/tests/pdo_016a.phpt +++ b/ext/pdo/tests/pdo_016a.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_BOUND w/o : +PDO Common: PDO::FETCH_BOUND w/o : --SKIPIF-- fetchColumn()); $stmt1 = null; $stmt2->execute(); -$cont = $stmt2->fetchAll(PDO_FETCH_COLUMN|PDO_FETCH_UNIQUE); +$cont = $stmt2->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE); var_dump($cont); echo "===WHILE===\n"; @@ -35,7 +35,7 @@ $stmt2->bindColumn('idx', $idx); $stmt2->bindColumn('txt', $txt); $stmt2->execute(); -while($stmt2->fetch(PDO_FETCH_BOUND)) { +while($stmt2->fetch(PDO::FETCH_BOUND)) { var_dump(array($idx=>$txt)); } @@ -57,7 +57,7 @@ foreach($cont as $idx => $txt) * after execute() has been called at least once */ $stmt3->bindColumn('txt', $col1); } - var_dump($stmt3->fetch(PDO_FETCH_BOUND)); + var_dump($stmt3->fetch(PDO::FETCH_BOUND)); $stmt3->closeCursor(); var_dump($stmt4->execute()); @@ -66,7 +66,7 @@ foreach($cont as $idx => $txt) * after execute() has been called at least once */ $stmt4->bindColumn('idx', $col2); } - var_dump($stmt4->fetch(PDO_FETCH_BOUND)); + var_dump($stmt4->fetch(PDO::FETCH_BOUND)); $stmt4->closeCursor(); var_dump(array($col2=>$col1)); } @@ -79,11 +79,11 @@ foreach($cont as $idx => $txt) { var_dump(array($idx=>$txt)); var_dump($stmt3->execute()); - var_dump($stmt3->fetch(PDO_FETCH_BOUND)); + var_dump($stmt3->fetch(PDO::FETCH_BOUND)); $stmt3->closeCursor(); var_dump($col1); var_dump($stmt4->execute()); - var_dump($stmt4->fetch(PDO_FETCH_BOUND)); + var_dump($stmt4->fetch(PDO::FETCH_BOUND)); $stmt4->closeCursor(); var_dump($col1); } @@ -94,7 +94,7 @@ $stmt2->bindColumn('idx', $col1); $stmt2->bindColumn('txt', $col1); $stmt2->execute(); -while($stmt2->fetch(PDO_FETCH_BOUND)) +while($stmt2->fetch(PDO::FETCH_BOUND)) { var_dump($col1); } diff --git a/ext/pdo/tests/pdo_017.phpt b/ext/pdo/tests/pdo_017.phpt index def132e5692..bb35bd8aca6 100644 --- a/ext/pdo/tests/pdo_017.phpt +++ b/ext/pdo/tests/pdo_017.phpt @@ -15,7 +15,7 @@ try { die('skip no working transactions: ' . $e->getMessage()); } -if ($db->getAttribute(PDO_ATTR_DRIVER_NAME) == 'mysql') { +if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { if (false === PDOTest::detect_transactional_mysql_engine($db)) { die('skip your mysql configuration does not support working transactions'); } @@ -26,7 +26,7 @@ if ($db->getAttribute(PDO_ATTR_DRIVER_NAME) == 'mysql') { require getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; $db = PDOTest::factory(); -if ($db->getAttribute(PDO_ATTR_DRIVER_NAME) == 'mysql') { +if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { $suf = ' Type=' . PDOTest::detect_transactional_mysql_engine($db); } else { $suf = ''; diff --git a/ext/pdo/tests/pdo_018.phpt b/ext/pdo/tests/pdo_018.phpt index 9cf2cc2fb86..1c57852a26f 100644 --- a/ext/pdo/tests/pdo_018.phpt +++ b/ext/pdo/tests/pdo_018.phpt @@ -72,10 +72,10 @@ $db->exec('INSERT INTO classtypes VALUES(1, \'TestBase\')'); $db->exec('INSERT INTO classtypes VALUES(2, \'TestDerived\')'); $db->exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, classtype int NULL, val VARCHAR(255))'); -$db->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION); +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); var_dump($db->query('SELECT COUNT(*) FROM classtypes')->fetchColumn()); -var_dump($db->query('SELECT id, name FROM classtypes ORDER by id')->fetchAll(PDO_FETCH_COLUMN|PDO_FETCH_UNIQUE)); +var_dump($db->query('SELECT id, name FROM classtypes ORDER by id')->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE)); $objs = array(); $objs[0] = new stdClass; @@ -94,7 +94,7 @@ foreach($objs as $obj) $ctype = NULL; /* set default for non stored class name */ $stmt->execute(); $stmt->bindColumn('id', $ctype); - $stmt->fetch(PDO_FETCH_BOUND); + $stmt->fetch(PDO::FETCH_BOUND); $ctypes[$cname] = $ctype; } @@ -126,12 +126,12 @@ foreach($objs as $idx => $obj) unset($stmt); echo "===DATA===\n"; -var_dump($db->query('SELECT test.val FROM test')->fetchAll(PDO_FETCH_COLUMN)); +var_dump($db->query('SELECT test.val FROM test')->fetchAll(PDO::FETCH_COLUMN)); echo "===FAILURE===\n"; try { - $db->query('SELECT classtypes.name AS name, test.val AS val FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id')->fetchAll(PDO_FETCH_CLASS|PDO_FETCH_CLASSTYPE|PDO_FETCH_SERIALIZE, 'TestLeaf', array()); + $db->query('SELECT classtypes.name AS name, test.val AS val FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id')->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_SERIALIZE, 'TestLeaf', array()); } catch (PDOException $e) { @@ -146,11 +146,11 @@ echo "===DATABASE===\n"; $stmt = $db->prepare('SELECT classtypes.name AS name, test.val AS val FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id WHERE (classtypes.id IS NULL OR classtypes.id > 0)'); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_ASSOC)); +var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); echo "===FETCHCLASS===\n"; $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_CLASS|PDO_FETCH_CLASSTYPE|PDO_FETCH_SERIALIZE, 'TestLeaf')); +var_dump($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_SERIALIZE, 'TestLeaf')); ?> diff --git a/ext/pdo/tests/pdo_019.phpt b/ext/pdo/tests/pdo_019.phpt index 36d70349b37..8ca3b67f0e2 100644 --- a/ext/pdo/tests/pdo_019.phpt +++ b/ext/pdo/tests/pdo_019.phpt @@ -25,7 +25,7 @@ var_dump($db->query('SELECT COUNT(*) FROM test')->fetchColumn()); $stmt = $db->prepare('SELECT idx, txt FROM test ORDER by idx'); $stmt->execute(); -$cont = $stmt->fetchAll(PDO_FETCH_COLUMN|PDO_FETCH_UNIQUE); +$cont = $stmt->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE); var_dump($cont); echo "===WHILE===\n"; @@ -34,7 +34,7 @@ $stmt->bindColumn('idx', $idx); $stmt->bindColumn('txt', $txt); $stmt->execute(); -while($stmt->fetch(PDO_FETCH_BOUND)) { +while($stmt->fetch(PDO::FETCH_BOUND)) { var_dump(array($idx=>$txt)); } diff --git a/ext/pdo/tests/pdo_023.phpt b/ext/pdo/tests/pdo_023.phpt index e6ad370ef53..996fa7c6456 100644 --- a/ext/pdo/tests/pdo_023.phpt +++ b/ext/pdo/tests/pdo_023.phpt @@ -49,7 +49,7 @@ class PDODatabaseX extends PDO function query($sql) { echo __METHOD__ . "()\n"; - $stmt = parent::prepare($sql, array(PDO_ATTR_STATEMENT_CLASS=>array('PDOStatementx'))); + $stmt = parent::prepare($sql, array(PDO::ATTR_STATEMENT_CLASS=>array('PDOStatementx'))); $stmt->execute(); return $stmt; } @@ -66,7 +66,7 @@ $db->query('INSERT INTO test VALUES(1, \'B\')'); $stmt = $db->query('SELECT val, id FROM test'); var_dump($stmt); -var_dump($stmt->fetchAll(PDO_FETCH_COLUMN|PDO_FETCH_UNIQUE)); +var_dump($stmt->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE)); $stmt = NULL; $db = NULL; diff --git a/ext/pdo/tests/pdo_025.phpt b/ext/pdo/tests/pdo_025.phpt index cc2c162b068..d65c93356db 100644 --- a/ext/pdo/tests/pdo_025.phpt +++ b/ext/pdo/tests/pdo_025.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_INTO +PDO Common: PDO::FETCH_INTO --SKIPIF-- prepare('SELECT * FROM test'); -$stmt->setFetchMode(PDO_FETCH_INTO, new Test); +$stmt->setFetchMode(PDO::FETCH_INTO, new Test); $stmt->execute(); foreach($stmt as $obj) { @@ -50,7 +50,7 @@ class Fail { public $val, $val2; } -$stmt->setFetchMode(PDO_FETCH_INTO, new Fail); +$stmt->setFetchMode(PDO::FETCH_INTO, new Fail); $stmt->execute(); foreach($stmt as $obj) { diff --git a/ext/pdo/tests/pdo_026.phpt b/ext/pdo/tests/pdo_026.phpt index 5207f8d3f5d..f61f16894ee 100644 --- a/ext/pdo/tests/pdo_026.phpt +++ b/ext/pdo/tests/pdo_026.phpt @@ -44,8 +44,8 @@ class PDODatabase extends PDO function query($sql) { echo __METHOD__ . "()\n"; - $stmt = $this->prepare($sql, array(PDO_ATTR_STATEMENT_CLASS=>array('PDOStatementx', array($this)))); - $stmt->setFetchMode(PDO_FETCH_ASSOC); + $stmt = $this->prepare($sql, array(PDO::ATTR_STATEMENT_CLASS=>array('PDOStatementx', array($this)))); + $stmt->setFetchMode(PDO::FETCH_ASSOC); $stmt->execute(); return $stmt; } diff --git a/ext/pdo/tests/pdo_027.phpt b/ext/pdo/tests/pdo_027.phpt index 468aeedc62d..226b4670aa9 100644 --- a/ext/pdo/tests/pdo_027.phpt +++ b/ext/pdo/tests/pdo_027.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO Common: PDO_FETCH_LAZY +PDO Common: PDO::FETCH_LAZY --SKIPIF-- exec('create table test (id int, name varchar(10) NULL)'); $db->exec("INSERT INTO test (id,name) VALUES(1,'test1')"); $db->exec("INSERT INTO test (id,name) VALUES(2,'test2')"); -foreach ($db->query("SELECT * FROM test", PDO_FETCH_LAZY) as $v) { +foreach ($db->query("SELECT * FROM test", PDO::FETCH_LAZY) as $v) { echo "lazy: " . $v->id.$v->name."\n"; } echo "End\n"; diff --git a/ext/pdo/tests/pdo_028.phpt b/ext/pdo/tests/pdo_028.phpt index 341917605f5..aaf0f56c41a 100644 --- a/ext/pdo/tests/pdo_028.phpt +++ b/ext/pdo/tests/pdo_028.phpt @@ -26,7 +26,7 @@ $stmt->execute(); $stmt = $db->prepare('SELECT * from test'); $stmt->execute(); -var_dump($stmt->fetchAll(PDO_FETCH_ASSOC)); +var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); ?> --EXPECT-- array(1) { diff --git a/ext/pdo/tests/pdo_test.inc b/ext/pdo/tests/pdo_test.inc index 2498d43f580..79df2baa29c 100644 --- a/ext/pdo/tests/pdo_test.inc +++ b/ext/pdo/tests/pdo_test.inc @@ -30,9 +30,9 @@ class PDOTest { $db->exec("DROP TABLE $table"); } - $db->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_WARNING); - $db->setAttribute(PDO_ATTR_CASE, PDO_CASE_LOWER); - $db->setAttribute(PDO_ATTR_STRINGIFY_FETCHES, true); + $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; } diff --git a/ext/pdo_mysql/pdo_mysql.c b/ext/pdo_mysql/pdo_mysql.c index 11c1d9876e8..018040dc8e9 100755 --- a/ext/pdo_mysql/pdo_mysql.c +++ b/ext/pdo_mysql/pdo_mysql.c @@ -75,7 +75,7 @@ ZEND_GET_MODULE(pdo_mysql) */ PHP_MINIT_FUNCTION(pdo_mysql) { - REGISTER_LONG_CONSTANT("PDO_MYSQL_ATTR_USE_BUFFERED_QUERY", (long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, CONST_CS|CONST_PERSISTENT); + REGISTER_PDO_CONST_LONG("PDO_MYSQL_ATTR_USE_BUFFERED_QUERY", (long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY); return php_pdo_register_driver(&pdo_mysql_driver); } diff --git a/ext/pdo_mysql/tests/pecl_bug_5200.phpt b/ext/pdo_mysql/tests/pecl_bug_5200.phpt index 41e41f4c91a..c6b319c78ab 100644 --- a/ext/pdo_mysql/tests/pecl_bug_5200.phpt +++ b/ext/pdo_mysql/tests/pecl_bug_5200.phpt @@ -14,7 +14,7 @@ $db = PDOTest::test_factory('ext/pdo_mysql/tests/common.phpt'); $db->exec("CREATE TABLE test (bar INT NOT NULL, phase enum('please_select', 'I', 'II', 'IIa', 'IIb', 'III', 'IV'))"); -foreach ($db->query('DESCRIBE test phase')->fetchAll(PDO_FETCH_ASSOC) as $row) { +foreach ($db->query('DESCRIBE test phase')->fetchAll(PDO::FETCH_ASSOC) as $row) { print_r($row); } diff --git a/ext/pdo_oci/tests/bug_33707.phpt b/ext/pdo_oci/tests/bug_33707.phpt index 78d3419b604..6583115778f 100644 --- a/ext/pdo_oci/tests/bug_33707.phpt +++ b/ext/pdo_oci/tests/bug_33707.phpt @@ -11,7 +11,7 @@ PDOTest::skip(); setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_SILENT); +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); $rs = $db->query('select blah from a_table_that_doesnt_exist'); var_dump($rs); diff --git a/ext/pdo_pgsql/pdo_pgsql.c b/ext/pdo_pgsql/pdo_pgsql.c index 58aa6394451..f945db80b47 100644 --- a/ext/pdo_pgsql/pdo_pgsql.c +++ b/ext/pdo_pgsql/pdo_pgsql.c @@ -77,7 +77,7 @@ ZEND_GET_MODULE(pdo_pgsql) PHP_MINIT_FUNCTION(pdo_pgsql) { php_pdo_register_driver(&pdo_pgsql_driver); - REGISTER_LONG_CONSTANT("PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT", PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, CONST_CS|CONST_PERSISTENT); + REGISTER_PDO_CONST_LONG("PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT", PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT); return SUCCESS; } /* }}} */ diff --git a/ext/pdo_pgsql/tests/bug_33876.phpt b/ext/pdo_pgsql/tests/bug_33876.phpt index ea10622786a..9fdbd8bff7e 100644 --- a/ext/pdo_pgsql/tests/bug_33876.phpt +++ b/ext/pdo_pgsql/tests/bug_33876.phpt @@ -11,7 +11,7 @@ PDOTest::skip(); setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_SILENT); +$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); $db->exec('CREATE TABLE test (foo varchar(5) NOT NULL, bar bool NOT NULL)'); $db->exec("INSERT INTO test VALUES('false','f')"); @@ -20,18 +20,18 @@ $db->exec("INSERT INTO test VALUES('true', 't')"); $res = $db->prepare('SELECT foo from test where bar = ?'); # this is the portable approach to binding a bool -$res->bindValue(1, false, PDO_PARAM_BOOL); +$res->bindValue(1, false, PDO::PARAM_BOOL); if (!$res->execute()) print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO_FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # this is the portable approach to binding a bool -$res->bindValue(1, true, PDO_PARAM_BOOL); +$res->bindValue(1, true, PDO::PARAM_BOOL); if (!$res->execute()) print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO_FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # true gets cast to string (because the implied default is string) @@ -39,35 +39,35 @@ else if (!$res->execute(array(true))) print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO_FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # Expected to fail; unless told otherwise, PDO assumes string inputs # false -> "" as string, which pgsql doesn't like if (!$res->execute(array(false))) print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO_FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # And now using emulator prepares echo "EMUL\n"; $res = $db->prepare('SELECT foo from test where bar = ?', array( - PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => true)); + PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => true)); # this is the portable approach to binding a bool -$res->bindValue(1, false, PDO_PARAM_BOOL); +$res->bindValue(1, false, PDO::PARAM_BOOL); if (!$res->execute()) print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO_FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # this is the portable approach to binding a bool -$res->bindValue(1, true, PDO_PARAM_BOOL); +$res->bindValue(1, true, PDO::PARAM_BOOL); if (!$res->execute()) print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO_FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # true gets cast to string (because the implied default is string) @@ -75,14 +75,14 @@ else if (!$res->execute(array(true))) print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO_FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC)); # Expected to fail; unless told otherwise, PDO assumes string inputs # false -> "" as string, which pgsql doesn't like if (!$res->execute(array(false))) print_r($res->errorInfo()); else - print_r($res->fetchAll(PDO_FETCH_ASSOC)); + print_r($res->fetchAll(PDO::FETCH_ASSOC));