summaryrefslogtreecommitdiff
path: root/ext/pdo/pdo_dbh.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo/pdo_dbh.c')
-rw-r--r--ext/pdo/pdo_dbh.c289
1 files changed, 152 insertions, 137 deletions
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index 375100b360..73a1c8aa17 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -34,7 +34,7 @@
#include "zend_interfaces.h"
#include "pdo_dbh_arginfo.h"
-static zend_result pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value);
+static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value);
void pdo_throw_exception(unsigned int driver_errcode, char *driver_errmsg, pdo_error_type *pdo_error)
{
@@ -148,21 +148,20 @@ PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt) /* {{{ */
ZVAL_UNDEF(&info);
if (dbh->methods->fetch_err) {
+ zval *item;
array_init(&info);
add_next_index_string(&info, *pdo_err);
- if (dbh->methods->fetch_err(dbh, stmt, &info)) {
- zval *item;
+ dbh->methods->fetch_err(dbh, stmt, &info);
- if ((item = zend_hash_index_find(Z_ARRVAL(info), 1)) != NULL
- && Z_TYPE_P(item) == IS_LONG) {
- native_code = Z_LVAL_P(item);
- }
+ if ((item = zend_hash_index_find(Z_ARRVAL(info), 1)) != NULL
+ && Z_TYPE_P(item) == IS_LONG) {
+ native_code = Z_LVAL_P(item);
+ }
- if ((item = zend_hash_index_find(Z_ARRVAL(info), 2)) != NULL) {
- supp = estrndup(Z_STRVAL_P(item), Z_STRLEN_P(item));
- }
+ if ((item = zend_hash_index_find(Z_ARRVAL(info), 2)) != NULL) {
+ supp = estrndup(Z_STRVAL_P(item), Z_STRLEN_P(item));
}
}
@@ -225,7 +224,7 @@ PHP_METHOD(PDO, __construct)
{
zval *object = ZEND_THIS;
pdo_dbh_t *dbh = NULL;
- zend_bool is_persistent = 0;
+ bool is_persistent = 0;
char *data_source;
size_t data_source_len;
char *colon;
@@ -376,6 +375,8 @@ PHP_METHOD(PDO, __construct)
php_error_docref(NULL, E_ERROR, "Out of memory");
}
+ /* pdo_dbh_attribute_set() can emit a Warning if the ERR_MODE is set to warning
+ * As we are in a constructor we override the behaviour by replacing the error handler */
zend_replace_error_handling(EH_THROW, pdo_exception_ce, &zeh);
if (!call_factory) {
@@ -408,7 +409,8 @@ options:
continue;
}
ZVAL_DEREF(attr_value);
- /* TODO: Check that this doesn't fail? */
+
+ /* TODO: Should the constructor fail when the attribute cannot be set? */
pdo_dbh_attribute_set(dbh, long_key, attr_value);
} ZEND_HASH_FOREACH_END();
}
@@ -452,10 +454,9 @@ static void pdo_stmt_construct(zend_execute_data *execute_data, pdo_stmt_t *stmt
zval query_string;
zend_string *key;
- ZVAL_STRINGL(&query_string, stmt->query_string, stmt->query_stringlen);
+ ZVAL_STR(&query_string, stmt->query_string);
key = zend_string_init("queryString", sizeof("queryString") - 1, 0);
zend_std_write_property(Z_OBJ_P(object), key, &query_string, NULL);
- zval_ptr_dtor(&query_string);
zend_string_release_ex(key, 0);
if (dbstmt_ce->constructor) {
@@ -490,22 +491,21 @@ static void pdo_stmt_construct(zend_execute_data *execute_data, pdo_stmt_t *stmt
PHP_METHOD(PDO, prepare)
{
pdo_stmt_t *stmt;
- char *statement;
- size_t statement_len;
+ zend_string *statement;
zval *options = NULL, *value, *item, ctor_args;
zend_class_entry *dbstmt_ce, *pce;
pdo_dbh_object_t *dbh_obj = Z_PDO_OBJECT_P(ZEND_THIS);
pdo_dbh_t *dbh = dbh_obj->inner;
ZEND_PARSE_PARAMETERS_START(1, 2)
- Z_PARAM_STRING(statement, statement_len)
+ Z_PARAM_STR(statement)
Z_PARAM_OPTIONAL
Z_PARAM_ARRAY(options)
ZEND_PARSE_PARAMETERS_END();
PDO_CONSTRUCT_CHECK;
- if (statement_len == 0) {
+ if (ZSTR_LEN(statement) == 0) {
zend_argument_value_error(1, "cannot be empty");
RETURN_THROWS();
}
@@ -557,8 +557,7 @@ PHP_METHOD(PDO, prepare)
stmt = Z_PDO_STMT_P(return_value);
/* unconditionally keep this for later reference */
- stmt->query_string = estrndup(statement, statement_len);
- stmt->query_stringlen = statement_len;
+ stmt->query_string = zend_string_copy(statement);
stmt->default_fetch_type = dbh->default_fetch_type;
stmt->dbh = dbh;
/* give it a reference to me */
@@ -566,7 +565,7 @@ PHP_METHOD(PDO, prepare)
/* we haven't created a lazy object yet */
ZVAL_UNDEF(&stmt->lazy_object_ref);
- if (dbh->methods->preparer(dbh, statement, statement_len, stmt, options)) {
+ if (dbh->methods->preparer(dbh, statement, stmt, options)) {
pdo_stmt_construct(execute_data, stmt, return_value, dbstmt_ce, &ctor_args);
return;
}
@@ -581,7 +580,7 @@ PHP_METHOD(PDO, prepare)
/* }}} */
-static zend_bool pdo_is_in_transaction(pdo_dbh_t *dbh) {
+static bool pdo_is_in_transaction(pdo_dbh_t *dbh) {
if (dbh->methods->in_transaction) {
return dbh->methods->in_transaction(dbh);
}
@@ -603,14 +602,13 @@ PHP_METHOD(PDO, beginTransaction)
}
if (!dbh->methods->begin) {
- /* TODO: this should be an exception; see the auto-commit mode
- * comments below */
+ /* Throw an exception when the driver does not support transactions */
zend_throw_exception_ex(php_pdo_get_exception(), 0, "This driver doesn't support transactions");
RETURN_THROWS();
}
if (dbh->methods->begin(dbh)) {
- dbh->in_txn = 1;
+ dbh->in_txn = true;
RETURN_TRUE;
}
@@ -634,7 +632,7 @@ PHP_METHOD(PDO, commit)
}
if (dbh->methods->commit(dbh)) {
- dbh->in_txn = 0;
+ dbh->in_txn = false;
RETURN_TRUE;
}
@@ -658,7 +656,7 @@ PHP_METHOD(PDO, rollBack)
}
if (dbh->methods->rollback(dbh)) {
- dbh->in_txn = 0;
+ dbh->in_txn = false;
RETURN_TRUE;
}
@@ -680,52 +678,89 @@ PHP_METHOD(PDO, inTransaction)
}
/* }}} */
-static zend_result pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /* {{{ */
+PDO_API bool pdo_get_long_param(zend_long *lval, zval *value)
{
- zend_long lval;
+ switch (Z_TYPE_P(value)) {
+ case IS_LONG:
+ case IS_TRUE:
+ case IS_FALSE:
+ *lval = zval_get_long(value);
+ return true;
+ case IS_STRING:
+ if (IS_LONG == is_numeric_str_function(Z_STR_P(value), lval, NULL)) {
+ return true;
+ }
+ /* fallthrough */
+ default:
+ zend_type_error("Attribute value must be of type int for selected attribute, %s given", zend_zval_type_name(value));
+ return false;
+ }
+}
+PDO_API bool pdo_get_bool_param(bool *bval, zval *value)
+{
+ switch (Z_TYPE_P(value)) {
+ case IS_TRUE:
+ *bval = true;
+ return true;
+ case IS_FALSE:
+ *bval = false;
+ return true;
+ case IS_LONG:
+ *bval = zval_is_true(value);
+ return true;
+ case IS_STRING: /* TODO Should string be allowed? */
+ default:
+ zend_type_error("Attribute value must be of type bool for selected attribute, %s given", zend_zval_type_name(value));
+ return false;
+ }
+}
-/* TODO: Make distinction between numeric and non-numeric strings */
-#define PDO_LONG_PARAM_CHECK \
- if (Z_TYPE_P(value) != IS_LONG && Z_TYPE_P(value) != IS_STRING && Z_TYPE_P(value) != IS_FALSE && Z_TYPE_P(value) != IS_TRUE) { \
- zend_type_error("Attribute value must be of type int for selected attribute, %s given", zend_zval_type_name(value)); \
- return FAILURE; \
- } \
+/* Return false on failure, true otherwise */
+static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /* {{{ */
+{
+ zend_long lval;
+ bool bval;
switch (attr) {
case PDO_ATTR_ERRMODE:
- PDO_LONG_PARAM_CHECK;
- lval = zval_get_long(value);
+ if (!pdo_get_long_param(&lval, value)) {
+ return false;
+ }
switch (lval) {
case PDO_ERRMODE_SILENT:
case PDO_ERRMODE_WARNING:
case PDO_ERRMODE_EXCEPTION:
dbh->error_mode = lval;
- return SUCCESS;
+ return true;
default:
zend_value_error("Error mode must be one of the PDO::ERRMODE_* constants");
- return FAILURE;
+ return false;
}
- return FAILURE;
+ return false;
case PDO_ATTR_CASE:
- PDO_LONG_PARAM_CHECK;
- lval = zval_get_long(value);
+ if (!pdo_get_long_param(&lval, value)) {
+ return false;
+ }
switch (lval) {
case PDO_CASE_NATURAL:
case PDO_CASE_UPPER:
case PDO_CASE_LOWER:
dbh->desired_case = lval;
- return SUCCESS;
+ return true;
default:
zend_value_error("Case folding mode must be one of the PDO::CASE_* constants");
- return FAILURE;
+ return false;
}
- return FAILURE;
+ return false;
case PDO_ATTR_ORACLE_NULLS:
- PDO_LONG_PARAM_CHECK;
- dbh->oracle_nulls = zval_get_long(value);
- return SUCCESS;
+ if (!pdo_get_long_param(&lval, value)) {
+ return false;
+ }
+ /* TODO Check for valid value (NULL_NATURAL, NULL_EMPTY_STRING, NULL_TO_STRING)? */
+ dbh->oracle_nulls = lval;
+ return true;
case PDO_ATTR_DEFAULT_FETCH_MODE:
if (Z_TYPE_P(value) == IS_ARRAY) {
@@ -733,24 +768,28 @@ static zend_result pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *v
if ((tmp = zend_hash_index_find(Z_ARRVAL_P(value), 0)) != NULL && Z_TYPE_P(tmp) == IS_LONG) {
if (Z_LVAL_P(tmp) == PDO_FETCH_INTO || Z_LVAL_P(tmp) == PDO_FETCH_CLASS) {
zend_value_error("PDO::FETCH_INTO and PDO::FETCH_CLASS cannot be set as the default fetch mode");
- return FAILURE;
+ return false;
}
}
+ lval = zval_get_long(value);
} else {
- PDO_LONG_PARAM_CHECK;
+ if (!pdo_get_long_param(&lval, value)) {
+ return false;
+ }
}
- lval = zval_get_long(value);
if (lval == PDO_FETCH_USE_DEFAULT) {
zend_value_error("Fetch mode must be a bitmask of PDO::FETCH_* constants");
- return FAILURE;
+ return false;
}
dbh->default_fetch_type = lval;
- return SUCCESS;
+ return true;
case PDO_ATTR_STRINGIFY_FETCHES:
- PDO_LONG_PARAM_CHECK;
- dbh->stringify = zval_get_long(value) ? 1 : 0;
- return SUCCESS;
+ if (!pdo_get_bool_param(&bval, value)) {
+ return false;
+ }
+ dbh->stringify = bval;
+ return true;
case PDO_ATTR_STATEMENT_CLASS: {
/* array(string classname, array(mixed ctor_args)) */
@@ -763,29 +802,29 @@ static zend_result pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *v
"PDO::ATTR_STATEMENT_CLASS cannot be used with persistent PDO instances"
);
PDO_HANDLE_DBH_ERR();
- return FAILURE;
+ return false;
}
if (Z_TYPE_P(value) != IS_ARRAY) {
zend_type_error("PDO::ATTR_STATEMENT_CLASS value must be of type array, %s given",
zend_zval_type_name(value));
- return FAILURE;
+ return false;
}
if ((item = zend_hash_index_find(Z_ARRVAL_P(value), 0)) == NULL) {
zend_value_error("PDO::ATTR_STATEMENT_CLASS value must be an array with the format "
"array(classname, constructor_args)");
- return FAILURE;
+ return false;
}
if (Z_TYPE_P(item) != IS_STRING || (pce = zend_lookup_class(Z_STR_P(item))) == NULL) {
zend_type_error("PDO::ATTR_STATEMENT_CLASS class must be a valid class");
- return FAILURE;
+ return false;
}
if (!instanceof_function(pce, pdo_dbstmt_ce)) {
zend_type_error("PDO::ATTR_STATEMENT_CLASS class must be derived from PDOStatement");
- return FAILURE;
+ return false;
}
if (pce->constructor && !(pce->constructor->common.fn_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_PROTECTED))) {
zend_type_error("User-supplied statement class cannot have a public constructor");
- return FAILURE;
+ return false;
}
dbh->def_stmt_ce = pce;
if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) {
@@ -796,15 +835,14 @@ static zend_result pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *v
if (Z_TYPE_P(item) != IS_ARRAY) {
zend_type_error("PDO::ATTR_STATEMENT_CLASS constructor_args must be of type ?array, %s given",
zend_zval_type_name(value));
- return FAILURE;
+ return false;
}
ZVAL_COPY(&dbh->def_stmt_ctor_args, item);
}
- return SUCCESS;
+ return true;
}
-
- default:
- ;
+ /* Don't throw a ValueError as the attribute might be a driver specific one */
+ default:;
}
if (!dbh->methods->set_attribute) {
@@ -813,7 +851,7 @@ static zend_result pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *v
PDO_DBH_CLEAR_ERR();
if (dbh->methods->set_attribute(dbh, attr, value)) {
- return SUCCESS;
+ return true;
}
fail:
@@ -822,7 +860,7 @@ fail:
} else {
PDO_HANDLE_DBH_ERR();
}
- return FAILURE;
+ return false;
}
/* }}} */
@@ -841,10 +879,7 @@ PHP_METHOD(PDO, setAttribute)
PDO_DBH_CLEAR_ERR();
PDO_CONSTRUCT_CHECK;
- if (pdo_dbh_attribute_set(dbh, attr, value) != FAILURE) {
- RETURN_TRUE;
- }
- RETURN_FALSE;
+ RETURN_BOOL(pdo_dbh_attribute_set(dbh, attr, value));
}
/* }}} */
@@ -907,6 +942,8 @@ PHP_METHOD(PDO, getAttribute)
RETURN_FALSE;
default:
+ /* No error state, just return as the return_value has been assigned
+ * by the get_attribute handler */
return;
}
}
@@ -916,23 +953,22 @@ PHP_METHOD(PDO, getAttribute)
PHP_METHOD(PDO, exec)
{
pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS);
- char *statement;
- size_t statement_len;
+ zend_string *statement;
zend_long ret;
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_STRING(statement, statement_len)
+ Z_PARAM_STR(statement)
ZEND_PARSE_PARAMETERS_END();
- if (statement_len == 0) {
+ if (ZSTR_LEN(statement) == 0) {
zend_argument_value_error(1, "cannot be empty");
RETURN_THROWS();
}
PDO_DBH_CLEAR_ERR();
PDO_CONSTRUCT_CHECK;
- ret = dbh->methods->doer(dbh, statement, statement_len);
- if(ret == -1) {
+ ret = dbh->methods->doer(dbh, statement);
+ if (ret == -1) {
PDO_HANDLE_DBH_ERR();
RETURN_FALSE;
} else {
@@ -945,12 +981,12 @@ PHP_METHOD(PDO, exec)
PHP_METHOD(PDO, lastInsertId)
{
pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS);
- char *name = NULL;
- size_t namelen;
+ zend_string *name = NULL;
+ zend_string *last_id = NULL;
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
- Z_PARAM_STRING_OR_NULL(name, namelen)
+ Z_PARAM_STR_OR_NULL(name)
ZEND_PARSE_PARAMETERS_END();
PDO_CONSTRUCT_CHECK;
@@ -960,19 +996,13 @@ PHP_METHOD(PDO, lastInsertId)
if (!dbh->methods->last_id) {
pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support lastInsertId()");
RETURN_FALSE;
- } else {
- size_t id_len;
- char *id;
- id = dbh->methods->last_id(dbh, name, &id_len);
- if (!id) {
- PDO_HANDLE_DBH_ERR();
- RETURN_FALSE;
- } else {
- //??? use zend_string ?
- RETVAL_STRINGL(id, id_len);
- efree(id);
- }
}
+ last_id = dbh->methods->last_id(dbh, name);
+ if (!last_id) {
+ PDO_HANDLE_DBH_ERR();
+ RETURN_FALSE;
+ }
+ RETURN_STR(last_id);
}
/* }}} */
@@ -1051,23 +1081,22 @@ fill_array:
PHP_METHOD(PDO, query)
{
pdo_stmt_t *stmt;
- char *statement;
- size_t statement_len;
+ zend_string *statement;
zend_long fetch_mode;
- zend_bool fetch_mode_is_null = 1;
+ bool fetch_mode_is_null = 1;
zval *args = NULL;
uint32_t num_args = 0;
pdo_dbh_object_t *dbh_obj = Z_PDO_OBJECT_P(ZEND_THIS);
pdo_dbh_t *dbh = dbh_obj->inner;
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s|l!*", &statement, &statement_len,
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "S|l!*", &statement,
&fetch_mode, &fetch_mode_is_null, &args, &num_args)) {
RETURN_THROWS();
}
PDO_CONSTRUCT_CHECK;
- if (statement_len == 0) {
+ if (ZSTR_LEN(statement) == 0) {
zend_argument_value_error(1, "cannot be empty");
RETURN_THROWS();
}
@@ -1080,25 +1109,22 @@ PHP_METHOD(PDO, query)
stmt = Z_PDO_STMT_P(return_value);
/* unconditionally keep this for later reference */
- stmt->query_string = estrndup(statement, statement_len);
- stmt->query_stringlen = statement_len;
-
+ stmt->query_string = zend_string_copy(statement);
+ stmt->active_query_string = zend_string_copy(stmt->query_string);
stmt->default_fetch_type = dbh->default_fetch_type;
- stmt->active_query_string = stmt->query_string;
- stmt->active_query_stringlen = statement_len;
stmt->dbh = dbh;
/* give it a reference to me */
ZVAL_OBJ_COPY(&stmt->database_object_handle, &dbh_obj->std);
/* we haven't created a lazy object yet */
ZVAL_UNDEF(&stmt->lazy_object_ref);
- if (dbh->methods->preparer(dbh, statement, statement_len, stmt, NULL)) {
+ if (dbh->methods->preparer(dbh, statement, stmt, NULL)) {
PDO_STMT_CLEAR_ERR();
if (fetch_mode_is_null || pdo_stmt_setup_fetch_mode(stmt, fetch_mode, 2, args, num_args)) {
/* now execute the statement */
PDO_STMT_CLEAR_ERR();
if (stmt->methods->executer(stmt)) {
- int ret = 1;
+ bool ret = true;
if (!stmt->executed) {
if (stmt->dbh->alloc_own_columns) {
ret = pdo_stmt_describe_columns(stmt);
@@ -1126,18 +1152,17 @@ PHP_METHOD(PDO, query)
}
/* }}} */
-/* {{{ quotes string for use in a query. The optional paramtype acts as a hint for drivers that have alternate quoting styles. The default value is PDO_PARAM_STR */
+/* {{{ quotes string for use in a query.
+ * The optional paramtype acts as a hint for drivers that have alternate quoting styles.
+ * The default value is PDO_PARAM_STR */
PHP_METHOD(PDO, quote)
{
pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS);
- char *str;
- size_t str_len;
+ zend_string *str;
zend_long paramtype = PDO_PARAM_STR;
- char *qstr;
- size_t qlen;
ZEND_PARSE_PARAMETERS_START(1, 2)
- Z_PARAM_STRING(str, str_len)
+ Z_PARAM_STR(str)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(paramtype)
ZEND_PARSE_PARAMETERS_END();
@@ -1150,13 +1175,7 @@ PHP_METHOD(PDO, quote)
RETURN_FALSE;
}
- if (dbh->methods->quoter(dbh, str, str_len, &qstr, &qlen, paramtype)) {
- RETVAL_STRINGL(qstr, qlen);
- efree(qstr);
- return;
- }
- PDO_HANDLE_DBH_ERR();
- RETURN_FALSE;
+ RETURN_STR(dbh->methods->quoter(dbh, str, paramtype));
}
/* }}} */
@@ -1194,7 +1213,7 @@ static void cls_method_pdtor(zval *el) /* {{{ */ {
/* }}} */
/* {{{ overloaded object handlers for PDO class */
-int pdo_hash_methods(pdo_dbh_object_t *dbh_obj, int kind)
+bool pdo_hash_methods(pdo_dbh_object_t *dbh_obj, int kind)
{
const zend_function_entry *funcs;
zend_internal_function func;
@@ -1203,11 +1222,11 @@ int pdo_hash_methods(pdo_dbh_object_t *dbh_obj, int kind)
pdo_dbh_t *dbh = dbh_obj->inner;
if (!dbh || !dbh->methods || !dbh->methods->get_driver_methods) {
- return 0;
+ return false;
}
funcs = dbh->methods->get_driver_methods(dbh, kind);
if (!funcs) {
- return 0;
+ return false;
}
dbh->cls_methods[kind] = pemalloc(sizeof(HashTable), dbh->is_persistent);
@@ -1259,7 +1278,7 @@ int pdo_hash_methods(pdo_dbh_object_t *dbh_obj, int kind)
funcs++;
}
- return 1;
+ return true;
}
static zend_function *dbh_method_get(zend_object **object, zend_string *method_name, const zval *key)
@@ -1288,16 +1307,15 @@ out:
return fbc;
}
-static int dbh_compare(zval *object1, zval *object2)
-{
- return ZEND_UNCOMPARABLE;
-}
-
static HashTable *dbh_get_gc(zend_object *object, zval **gc_data, int *gc_count)
{
pdo_dbh_t *dbh = php_pdo_dbh_fetch_inner(object);
- *gc_data = &dbh->def_stmt_ctor_args;
- *gc_count = 1;
+ zend_get_gc_buffer *gc_buffer = zend_get_gc_buffer_create();
+ zend_get_gc_buffer_add_zval(gc_buffer, &dbh->def_stmt_ctor_args);
+ if (dbh->methods && dbh->methods->get_gc) {
+ dbh->methods->get_gc(dbh, gc_buffer);
+ }
+ zend_get_gc_buffer_use(gc_buffer, gc_data, gc_count);
return zend_std_get_properties(object);
}
@@ -1306,10 +1324,7 @@ static void pdo_dbh_free_storage(zend_object *std);
void pdo_dbh_init(void)
{
- zend_class_entry ce;
-
- INIT_CLASS_ENTRY(ce, "PDO", class_PDO_methods);
- pdo_dbh_ce = zend_register_internal_class(&ce);
+ pdo_dbh_ce = register_class_PDO();
pdo_dbh_ce->create_object = pdo_dbh_new;
pdo_dbh_ce->serialize = zend_class_serialize_deny;
pdo_dbh_ce->unserialize = zend_class_unserialize_deny;
@@ -1320,7 +1335,7 @@ void pdo_dbh_init(void)
pdo_dbh_object_handlers.free_obj = pdo_dbh_free_storage;
pdo_dbh_object_handlers.clone_obj = NULL;
pdo_dbh_object_handlers.get_method = dbh_method_get;
- pdo_dbh_object_handlers.compare = dbh_compare;
+ pdo_dbh_object_handlers.compare = zend_objects_not_comparable;
pdo_dbh_object_handlers.get_gc = dbh_get_gc;
REGISTER_PDO_CLASS_CONST_LONG("PARAM_BOOL", (zend_long)PDO_PARAM_BOOL);
@@ -1409,7 +1424,7 @@ void pdo_dbh_init(void)
REGISTER_PDO_CLASS_CONST_LONG("CURSOR_SCROLL", (zend_long)PDO_CURSOR_SCROLL);
}
-static void dbh_free(pdo_dbh_t *dbh, zend_bool free_persistent)
+static void dbh_free(pdo_dbh_t *dbh, bool free_persistent)
{
int i;
@@ -1464,7 +1479,7 @@ static void pdo_dbh_free_storage(zend_object *std)
pdo_dbh_t *dbh = php_pdo_dbh_fetch_inner(std);
if (dbh->in_txn && dbh->methods && dbh->methods->rollback) {
dbh->methods->rollback(dbh);
- dbh->in_txn = 0;
+ dbh->in_txn = false;
}
if (dbh->is_persistent && dbh->methods && dbh->methods->persistent_shutdown) {