43 zval error_info,pdo_exception;
44 char *pdo_exception_message;
53 spprintf(&pdo_exception_message, 0,
"SQLSTATE[%s] [%d] %s",*pdo_error, driver_errcode, driver_errmsg);
63 efree(pdo_exception_message);
92 msg =
"<<Unknown error>>";
96 spprintf(&message, 0,
"SQLSTATE[%s]: %s: %s", *pdo_err,
msg, supp);
98 spprintf(&message, 0,
"SQLSTATE[%s]: %s", *pdo_err,
msg);
131 const char *
msg =
"<<Unknown>>";
148 msg =
"<<Unknown error>>";
170 if (native_code && supp) {
173 message =
strpprintf(0,
"SQLSTATE[%s]: %s: %s", *pdo_err,
msg, supp);
208static char *dsn_from_uri(
char *uri,
char *
buf,
size_t buflen)
230 if (called_scope !=
pdo_dbh_ce && instanceof_function(called_scope, ce)) {
231 ce_based_on_called_object = called_scope;
236 if (ce_based_on_called_object) {
237 if (ce_based_on_driver_name) {
238 if (!instanceof_function(ce_based_on_called_object, ce_based_on_driver_name)) {
240 "%s::%s() cannot be used for connecting to the \"%s\" driver, "
241 "either call %s::%s() or PDO::%s() instead",
243 new_zval_object ?
"connect" :
"__construct",
246 new_zval_object ?
"connect" :
"__construct",
247 new_zval_object ?
"connect" :
"__construct"
253 if (new_zval_object) {
259 "%s::%s() cannot be used for connecting to an unknown driver, "
260 "call PDO::%s() instead",
262 new_zval_object ?
"connect" :
"__construct",
263 new_zval_object ?
"connect" :
"__construct"
274 if (ce_based_on_driver_name) {
278 "%s::%s() cannot be used for connecting to the \"%s\" driver, "
279 "either call %s::%s() or PDO::%s() instead",
281 new_zval_object ?
"connect" :
"__construct",
284 new_zval_object ?
"connect" :
"__construct",
285 new_zval_object ?
"connect" :
"__construct"
290 if (new_zval_object) {
293 }
else if (new_zval_object) {
304 bool is_persistent = 0;
306 size_t data_source_len;
308 char *username=
NULL, *password=
NULL;
309 size_t usernamelen, passwordlen;
313 int call_factory = 1;
325 colon =
strchr(data_source,
':');
329 char *ini_dsn =
NULL;
331 snprintf(alt_dsn,
sizeof(alt_dsn),
"pdo.dsn.%s", data_source);
337 data_source = ini_dsn;
338 colon =
strchr(data_source,
':');
346 if (!
strncmp(data_source,
"uri:",
sizeof(
"uri:")-1)) {
348 data_source = dsn_from_uri(data_source +
sizeof(
"uri:")-1, alt_dsn,
sizeof(alt_dsn));
353 colon =
strchr(data_source,
':');
371 if (!create_driver_specific_pdo_object(driver, called_scope, new_zval_object)) {
375 if (new_zval_object) {
378 dbh = php_pdo_dbh_fetch_inner(current_object);
384 char *hashkey =
NULL;
393 plen =
spprintf(&hashkey, 0,
"PDO:DBH:DSN=%s:%s:%s:%s", data_source,
394 username ? username :
"",
395 password ? password :
"",
399 is_persistent = zval_get_long(
v) ? 1 : 0;
400 plen =
spprintf(&hashkey, 0,
"PDO:DBH:DSN=%s:%s:%s", data_source,
401 username ? username :
"",
402 password ? password :
"");
408 if ((le = zend_hash_str_find_ptr(&
EG(persistent_list), hashkey, plen)) !=
NULL) {
426 pdbh =
pecalloc(1,
sizeof(*pdbh), 1);
441 if (new_zval_object) {
444 pdo_obj = php_pdo_dbh_fetch_object(current_object);
448 pdo_obj->
inner = pdbh;
509 pdo_dbh_attribute_set(dbh, long_key, attr_value);
606 zend_type_error(
"PDO::ATTR_STATEMENT_CLASS value must be of type array, %s given",
611 zend_value_error(
"PDO::ATTR_STATEMENT_CLASS value must be an array with the format "
612 "array(classname, constructor_args)");
616 zend_type_error(
"PDO::ATTR_STATEMENT_CLASS class must be a valid class");
621 zend_type_error(
"PDO::ATTR_STATEMENT_CLASS class must be derived from PDOStatement");
625 zend_type_error(
"User-supplied statement class cannot have a public constructor");
630 zend_type_error(
"PDO::ATTR_STATEMENT_CLASS constructor_args must be of type ?array, %s given",
643 if (!pdo_stmt_instantiate(dbh,
return_value, dbstmt_ce, &ctor_args)) {
676static bool pdo_is_in_transaction(
pdo_dbh_t *dbh) {
692 if (pdo_is_in_transaction(dbh)) {
722 if (!pdo_is_in_transaction(dbh)) {
746 if (!pdo_is_in_transaction(dbh)) {
780 *lval = zval_get_long(
value);
845 zend_value_error(
"Case folding mode must be one of the PDO::CASE_* constants");
863 zend_value_error(
"PDO::FETCH_INTO and PDO::FETCH_CLASS cannot be set as the default fetch mode");
867 lval = zval_get_long(
value);
898 "PDO::ATTR_STATEMENT_CLASS cannot be used with persistent PDO instances"
904 zend_type_error(
"PDO::ATTR_STATEMENT_CLASS value must be of type array, %s given",
909 zend_value_error(
"PDO::ATTR_STATEMENT_CLASS value must be an array with the format "
910 "array(classname, constructor_args)");
914 zend_type_error(
"PDO::ATTR_STATEMENT_CLASS class must be a valid class");
918 zend_type_error(
"PDO::ATTR_STATEMENT_CLASS class must be derived from PDOStatement");
922 zend_type_error(
"User-supplied statement class cannot have a public constructor");
932 zend_type_error(
"PDO::ATTR_STATEMENT_CLASS constructor_args must be of type ?array, %s given",
1139 int error_count_diff = 0;
1140 int error_expected_count = 3;
1170 if (error_expected_count > error_count) {
1173 error_count_diff = error_expected_count - error_count;
1174 for (current_index = 0; current_index < error_count_diff; current_index++) {
1187 bool fetch_mode_is_null = 1;
1284 if (quoted ==
NULL) {
1308static void cls_method_dtor(
zval *el) {
1310 if (
func->common.function_name) {
1320static void cls_method_pdtor(
zval *el) {
1322 if (
func->common.function_name) {
1356 while (funcs->
fname) {
1391 func.required_num_args = 0;
1422 lc_method_name = zend_string_tolower(method_name);
1433 pdo_dbh_t *dbh = php_pdo_dbh_fetch_inner(
object);
1439 zend_get_gc_buffer_use(gc_buffer, gc_data, gc_count);
1445static void pdo_dbh_free_storage(
zend_object *std);
1451 pdo_dbh_ce->default_object_handlers = &pdo_dbh_object_handlers;
1455 pdo_dbh_object_handlers.free_obj = pdo_dbh_free_storage;
1456 pdo_dbh_object_handlers.clone_obj =
NULL;
1457 pdo_dbh_object_handlers.get_method = dbh_method_get;
1459 pdo_dbh_object_handlers.get_gc = dbh_get_gc;
1462static void dbh_free(
pdo_dbh_t *dbh,
bool free_persistent)
1475 if (!free_persistent && (--dbh->
refcount)) {
1514 pdo_dbh_t *dbh = php_pdo_dbh_fetch_inner(std);
1541 zend_std_get_properties_ex(&dbh->
std);
strchr(string $haystack, string $needle, bool $before_needle=false)
memset(ptr, 0, type->size)
zend_ffi_ctype_name_buf buf
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
pdo_driver_t * pdo_find_driver(const char *name, int namelen)
zend_class_entry * pdo_dbstmt_ce
HashTable pdo_driver_specific_ce_hash
HashTable pdo_driver_hash
zend_class_entry * pdo_exception_ce
zend_class_entry * pdo_dbh_ce
PDO_API zend_class_entry * php_pdo_get_exception(void)
int php_pdo_list_entry(void)
PDO_API bool pdo_get_long_param(zend_long *lval, zval *value)
void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, pdo_error_type sqlstate, const char *supp)
void pdo_dbh_init(int module_number)
PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt)
PDO_API bool pdo_get_bool_param(bool *bval, zval *value)
bool pdo_hash_methods(pdo_dbh_object_t *dbh_obj, int kind)
void pdo_throw_exception(unsigned int driver_errcode, char *driver_errmsg, pdo_error_type *pdo_error)
PDO_API void php_pdo_internal_construct_driver(INTERNAL_FUNCTION_PARAMETERS, zend_object *current_object, zend_class_entry *called_scope, zval *new_zval_object)
zend_object * pdo_dbh_new(zend_class_entry *ce)
const char * pdo_sqlstate_state_to_description(char *state)
bool pdo_stmt_describe_columns(pdo_stmt_t *stmt)
bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_arg_num, zval *args, uint32_t variadic_num_args)
PHPAPI int cfg_get_string(const char *varname, char **result)
PHP_JSON_API size_t int options
#define PDO_CONSTRUCT_CHECK
struct _pdo_dbh_t pdo_dbh_t
struct _pdo_stmt_t pdo_stmt_t
@ PDO_DBH_DRIVER_METHOD_KIND_DBH
@ PDO_DBH_DRIVER_METHOD_KIND__MAX
#define Z_PDO_OBJECT_P(zv)
struct _pdo_dbh_object_t pdo_dbh_object_t
@ PDO_ATTR_STATEMENT_CLASS
@ PDO_ATTR_STRINGIFY_FETCHES
@ PDO_ATTR_DEFAULT_FETCH_MODE
#define PDO_HANDLE_DBH_ERR()
#define PDO_STMT_CLEAR_ERR()
#define PDO_HANDLE_STMT_ERR()
#define PDO_DBH_CLEAR_ERR()
unsigned char key[REFLECTION_KEY_LEN]
struct _php_stream php_stream
#define php_stream_get_line(stream, buf, maxlen, retlen)
#define php_stream_close(stream)
#define php_stream_open_wrapper(path, mode, options, opened)
HashTable * cls_methods[PDO_DBH_DRIVER_METHOD_KIND__MAX]
const char * persistent_id
enum pdo_case_conversion native_case desired_case
enum pdo_fetch_type default_fetch_type
pdo_error_type error_code
enum pdo_error_mode error_mode
unsigned alloc_own_columns
zend_class_entry * def_stmt_ce
const struct pdo_dbh_methods * methods
zend_string * active_query_string
zend_string * query_string
pdo_error_type error_code
const struct pdo_stmt_methods * methods
enum pdo_fetch_type default_fetch_type
zval database_object_handle
zend_function * constructor
const struct _zend_internal_arg_info * arg_info
uintptr_t required_num_args
pdo_dbh_txn_func rollback
pdo_dbh_fetch_error_func fetch_err
pdo_dbh_get_driver_methods_func get_driver_methods
pdo_dbh_check_liveness_func check_liveness
pdo_dbh_get_gc_func get_gc
pdo_dbh_quote_func quoter
pdo_dbh_get_attr_func get_attribute
pdo_dbh_last_id_func last_id
pdo_dbh_close_func closer
pdo_dbh_set_attr_func set_attribute
pdo_dbh_prepare_func preparer
pdo_dbh_request_shutdown persistent_shutdown
pdo_dbh_txn_func in_transaction
int(* db_handle_factory)(pdo_dbh_t *dbh, zval *driver_options)
pdo_stmt_execute_func executer
struct _zend_function::@236135173067030250234125302313220025134003177336 common
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format,...)
ZEND_API ZEND_COLD void zend_type_error(const char *format,...)
ZEND_API ZEND_COLD void zend_value_error(const char *format,...)
#define INTERNAL_FUNCTION_PARAMETERS
ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current)
ZEND_API void zend_restore_error_handling(zend_error_handling *saved)
#define INTERNAL_FUNCTION_PARAM_PASSTHRU
ZEND_API zend_result add_next_index_null(zval *arg)
ZEND_API const char * zend_zval_value_name(const zval *arg)
ZEND_API zend_result add_next_index_stringl(zval *arg, const char *str, size_t length)
ZEND_API zend_result add_next_index_long(zval *arg, zend_long n)
ZEND_API zend_result object_init_ex(zval *arg, zend_class_entry *class_type)
ZEND_API ZEND_COLD void zend_argument_error(zend_class_entry *error_ce, uint32_t arg_num, const char *format,...)
ZEND_API void zend_update_property_string(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, const char *value)
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
ZEND_API void zend_update_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zval *value)
ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type)
ZEND_API ZEND_COLD void zend_argument_must_not_be_empty_error(uint32_t arg_num)
ZEND_API void zend_update_property_long(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_long value)
ZEND_API zend_result add_next_index_string(zval *arg, const char *str)
ZEND_API void zend_update_property_str(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_string *value)
ZEND_API zend_result add_next_index_str(zval *arg, zend_string *str)
#define Z_PARAM_ARRAY_OR_NULL(dest)
#define RETURN_STRINGL(s, l)
#define ZEND_PARSE_PARAMETERS_END()
struct _zend_function_entry zend_function_entry
#define Z_PARAM_STR_OR_NULL(dest)
#define ZEND_PARSE_PARAMETERS_NONE()
#define Z_PARAM_STRING(dest, dest_len)
#define Z_PARAM_STR(dest)
#define Z_PARAM_STRING_OR_NULL(dest, dest_len)
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
#define Z_PARAM_LONG(dest)
#define Z_PARAM_ARRAY(dest)
ZEND_API void zend_call_known_function(zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr, uint32_t param_count, zval *params, HashTable *named_params)
#define Z_PARAM_ZVAL(dest)
#define estrndup(s, length)
#define pestrdup(s, persistent)
#define ecalloc(nmemb, size)
#define pefree(ptr, persistent)
#define pemalloc(size, persistent)
#define pecalloc(nmemb, size, persistent)
strncmp(string $string1, string $string2, int $length)
zend_string_release_ex(func->internal_function.function_name, 0)
ZEND_API void zend_set_function_arg_flags(zend_function *func)
struct _zend_internal_function_info zend_internal_function_info
#define ZEND_INTERNAL_FUNCTION
#define ZEND_ARG_SEND_MODE(arg_info)
struct _zend_internal_arg_info zend_internal_arg_info
#define ZEND_ARG_IS_VARIADIC(arg_info)
#define ZEND_ACC_VARIADIC
struct _zend_internal_function zend_internal_function
#define ZEND_ACC_RETURN_REFERENCE
#define ZEND_ACC_PROTECTED
#define ZEND_ACC_NEVER_CACHE
ZEND_API zend_class_entry * zend_ce_exception
ZEND_API ZEND_COLD void zend_throw_exception_object(zval *exception)
ZEND_API ZEND_COLD zend_object * zend_throw_exception(zend_class_entry *exception_ce, const char *message, zend_long code)
ZEND_API ZEND_COLD zend_object * zend_throw_exception_ex(zend_class_entry *exception_ce, zend_long code, const char *format,...)
ZEND_API zend_class_entry * zend_lookup_class(zend_string *name)
ZEND_API size_t zend_internal_run_time_cache_reserved_size(void)
union _zend_function zend_function
ZEND_API zend_get_gc_buffer * zend_get_gc_buffer_create(void)
ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht)
ZEND_API zval *ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h)
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent)
#define ZEND_HASH_MAP_FOREACH_PTR(ht, _ptr)
#define ZEND_HASH_FOREACH_KEY_VAL(ht, _h, _key, _val)
#define ZEND_HASH_FOREACH_END()
ZEND_API zend_resource * zend_register_persistent_resource(const char *key, size_t key_len, void *rsrc_pointer, int rsrc_type)
ZEND_API void ZEND_FASTCALL zend_list_close(zend_resource *res)
#define ZEND_RSRC_DTOR_FUNC(name)
struct _zend_string zend_string
#define ZEND_MAP_PTR(ptr)
ZEND_API zend_function * zend_std_get_method(zend_object **obj_ptr, zend_string *method_name, const zval *key)
ZEND_API int zend_objects_not_comparable(zval *o1, zval *o2)
ZEND_API HashTable * zend_std_get_properties(zend_object *zobj)
ZEND_API const zend_object_handlers std_object_handlers
ZEND_API zval * zend_std_write_property(zend_object *zobj, zend_string *name, zval *value, void **cache_slot)
ZEND_API void ZEND_FASTCALL zend_object_std_init(zend_object *object, zend_class_entry *ce)
ZEND_API void zend_object_std_dtor(zend_object *object)
#define ZEND_OBSERVER_ENABLED
ZEND_API char *ZEND_FASTCALL zend_str_tolower_copy(char *dest, const char *source, size_t length)
ZEND_API uint8_t ZEND_FASTCALL is_numeric_str_function(const zend_string *str, zend_long *lval, double *dval)
#define EXPECTED(condition)
#define XtOffsetOf(s_type, field)
#define UNEXPECTED(condition)
struct _zend_class_entry zend_class_entry
struct _zend_object zend_object
#define ZSTR_INIT_LITERAL(s, persistent)
#define Z_STRVAL_P(zval_p)
#define Z_ISUNDEF_P(zval_p)
#define Z_ARRVAL_P(zval_p)
struct _zend_resource zend_resource
struct _zend_array HashTable
#define Z_STRLEN_P(zval_p)
#define Z_OBJCE_P(zval_p)
#define ZVAL_OBJ_COPY(z, o)
struct _zend_object_handlers zend_object_handlers
#define ZVAL_COPY_VALUE(z, v)
ZEND_API void zval_ptr_dtor(zval *zval_ptr)