mirror of
https://github.com/php/php-src.git
synced 2024-11-24 18:34:21 +08:00
MFH: Make PDO use class constants
This commit is contained in:
parent
9986219353
commit
bfe844e41e
1
NEWS
1
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.
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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 */
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_ASSOC
|
||||
PDO Common: PDO::FETCH_ASSOC
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -21,7 +21,7 @@ $db->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) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_NUM
|
||||
PDO Common: PDO::FETCH_NUM
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -21,7 +21,7 @@ $db->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) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_BOTH
|
||||
PDO Common: PDO::FETCH_BOTH
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -21,7 +21,7 @@ $db->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) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_OBJ
|
||||
PDO Common: PDO::FETCH_OBJ
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -21,7 +21,7 @@ $db->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) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_CLASS
|
||||
PDO Common: PDO::FETCH_CLASS
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -39,13 +39,13 @@ class TestDerived extends TestBase
|
||||
}
|
||||
|
||||
$stmt->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--
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_GROUP
|
||||
PDO Common: PDO::FETCH_GROUP
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -21,10 +21,10 @@ $db->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--
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_UNIQUE
|
||||
PDO Common: PDO::FETCH_UNIQUE
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -21,10 +21,10 @@ $db->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--
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_UNIQUE conflict
|
||||
PDO Common: PDO::FETCH_UNIQUE conflict
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -21,7 +21,7 @@ $db->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--
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_CLASSTYPE
|
||||
PDO Common: PDO::FETCH_CLASSTYPE
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -50,10 +50,10 @@ class Test3
|
||||
}
|
||||
|
||||
$stmt->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--
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_CLASSTYPE and GROUP/UNIQUE
|
||||
PDO Common: PDO::FETCH_CLASSTYPE and GROUP/UNIQUE
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -51,10 +51,10 @@ class Test3
|
||||
|
||||
|
||||
$stmt->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--
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_FUNC and statement overloading
|
||||
PDO Common: PDO::FETCH_FUNC and statement overloading
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -35,7 +35,7 @@ class DerivedStatement extends PDOStatement
|
||||
|
||||
$select1 = $db->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--
|
||||
|
@ -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());
|
||||
|
||||
?>
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_COLUMN
|
||||
PDO Common: PDO::FETCH_COLUMN
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -21,22 +21,22 @@ $select1 = $db->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--
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_BOUND
|
||||
PDO Common: PDO::FETCH_BOUND
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -26,7 +26,7 @@ var_dump($stmt1->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);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_BOUND w/o :
|
||||
PDO Common: PDO::FETCH_BOUND w/o :
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -26,7 +26,7 @@ var_dump($stmt1->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);
|
||||
}
|
||||
|
@ -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 = '';
|
||||
|
@ -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'));
|
||||
|
||||
|
||||
?>
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_INTO
|
||||
PDO Common: PDO::FETCH_INTO
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -36,7 +36,7 @@ class Test {
|
||||
}
|
||||
|
||||
$stmt = $db->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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
PDO Common: PDO_FETCH_LAZY
|
||||
PDO Common: PDO::FETCH_LAZY
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded('pdo')) die('skip');
|
||||
@ -17,7 +17,7 @@ $db->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";
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ PDOTest::skip();
|
||||
<?php
|
||||
require 'ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory('ext/pdo_oci/tests/common.phpt');
|
||||
$db->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);
|
||||
|
@ -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;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -11,7 +11,7 @@ PDOTest::skip();
|
||||
<?php
|
||||
require 'ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory('ext/pdo_pgsql/tests/common.phpt');
|
||||
$db->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));
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user