Lines Matching refs:dbh

39 static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value);
68 void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, pdo_error_type sqlstate, const char *su… in pdo_raise_impl_error() argument
70 pdo_error_type *pdo_err = &dbh->error_code; in pdo_raise_impl_error()
74 if (dbh->error_mode == PDO_ERRMODE_SILENT) { in pdo_raise_impl_error()
101 if (dbh->error_mode != PDO_ERRMODE_EXCEPTION) { in pdo_raise_impl_error()
128 PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt) /* {{{ */ in pdo_handle_error() argument
130 pdo_error_type *pdo_err = &dbh->error_code; in pdo_handle_error()
137 if (dbh->error_mode == PDO_ERRMODE_SILENT) { in pdo_handle_error()
152 if (dbh->methods->fetch_err) { in pdo_handle_error()
158 dbh->methods->fetch_err(dbh, stmt, &info); in pdo_handle_error()
178 if (dbh->error_mode == PDO_ERRMODE_WARNING) { in pdo_handle_error()
280 pdo_dbh_t *dbh = NULL; in internal_construct() local
352 dbh = Z_PDO_DBH_P(new_zval_object); in internal_construct()
354 dbh = php_pdo_dbh_fetch_inner(object); in internal_construct()
409 pdbh->def_stmt_ce = dbh->def_stmt_ce; in internal_construct()
414 efree(dbh); in internal_construct()
418 dbh = pdbh; in internal_construct()
427 dbh->data_source_len = strlen(colon + 1); in internal_construct()
428 dbh->data_source = (const char*)pestrdup(colon + 1, is_persistent); in internal_construct()
429 dbh->username = username ? pestrdup(username, is_persistent) : NULL; in internal_construct()
430 dbh->password = password ? pestrdup(password, is_persistent) : NULL; in internal_construct()
431 dbh->default_fetch_type = PDO_FETCH_BOTH; in internal_construct()
434 dbh->auto_commit = pdo_attr_lval(options, PDO_ATTR_AUTOCOMMIT, 1); in internal_construct()
435 dbh->error_mode = pdo_attr_lval(options, PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION); in internal_construct()
437 if (!dbh->data_source || (username && !dbh->username) || (password && !dbh->password)) { in internal_construct()
450 if (driver->db_handle_factory(dbh, options)) { in internal_construct()
458 (char*)dbh->persistent_id, dbh->persistent_id_len, dbh, php_pdo_list_entry())) == NULL) { in internal_construct()
463 dbh->driver = driver; in internal_construct()
477 pdo_dbh_attribute_set(dbh, long_key, attr_value); in internal_construct()
487 dbh->refcount--; in internal_construct()
511 static zval *pdo_stmt_instantiate(pdo_dbh_t *dbh, zval *object, zend_class_entry *dbstmt_ce, zval *… in pdo_stmt_instantiate() argument
555 pdo_dbh_t *dbh = dbh_obj->inner; in PHP_METHOD() local
607 dbstmt_ce = dbh->def_stmt_ce; in PHP_METHOD()
608 ZVAL_COPY_VALUE(&ctor_args, &dbh->def_stmt_ctor_args); in PHP_METHOD()
611 if (!pdo_stmt_instantiate(dbh, return_value, dbstmt_ce, &ctor_args)) { in PHP_METHOD()
618 stmt->default_fetch_type = dbh->default_fetch_type; in PHP_METHOD()
619 stmt->dbh = dbh; in PHP_METHOD()
625 if (dbh->methods->preparer(dbh, statement, stmt, options)) { in PHP_METHOD()
644 static bool pdo_is_in_transaction(pdo_dbh_t *dbh) { in pdo_is_in_transaction() argument
645 if (dbh->methods->in_transaction) { in pdo_is_in_transaction()
646 return dbh->methods->in_transaction(dbh); in pdo_is_in_transaction()
648 return dbh->in_txn; in pdo_is_in_transaction()
654 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
660 if (pdo_is_in_transaction(dbh)) { in PHP_METHOD()
665 if (!dbh->methods->begin) { in PHP_METHOD()
671 if (dbh->methods->begin(dbh)) { in PHP_METHOD()
672 dbh->in_txn = true; in PHP_METHOD()
684 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
690 if (!pdo_is_in_transaction(dbh)) { in PHP_METHOD()
695 if (dbh->methods->commit(dbh)) { in PHP_METHOD()
696 dbh->in_txn = false; in PHP_METHOD()
708 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
714 if (!pdo_is_in_transaction(dbh)) { in PHP_METHOD()
719 if (dbh->methods->rollback(dbh)) { in PHP_METHOD()
720 dbh->in_txn = false; in PHP_METHOD()
732 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
738 RETURN_BOOL(pdo_is_in_transaction(dbh)); in PHP_METHOD()
780 static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /* {{{ */ in pdo_dbh_attribute_set() argument
794 dbh->error_mode = lval; in pdo_dbh_attribute_set()
810 dbh->desired_case = lval; in pdo_dbh_attribute_set()
823 dbh->oracle_nulls = lval; in pdo_dbh_attribute_set()
845 dbh->default_fetch_type = lval; in pdo_dbh_attribute_set()
852 dbh->stringify = bval; in pdo_dbh_attribute_set()
853 if (dbh->methods->set_attribute) { in pdo_dbh_attribute_set()
854 dbh->methods->set_attribute(dbh, attr, value); in pdo_dbh_attribute_set()
863 if (dbh->is_persistent) { in pdo_dbh_attribute_set()
865 pdo_raise_impl_error(dbh, NULL, "HY000", in pdo_dbh_attribute_set()
893 dbh->def_stmt_ce = pce; in pdo_dbh_attribute_set()
894 if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) { in pdo_dbh_attribute_set()
895 zval_ptr_dtor(&dbh->def_stmt_ctor_args); in pdo_dbh_attribute_set()
896 ZVAL_UNDEF(&dbh->def_stmt_ctor_args); in pdo_dbh_attribute_set()
904 ZVAL_COPY(&dbh->def_stmt_ctor_args, item); in pdo_dbh_attribute_set()
912 if (!dbh->methods->set_attribute) { in pdo_dbh_attribute_set()
917 if (dbh->methods->set_attribute(dbh, attr, value)) { in pdo_dbh_attribute_set()
922 if (!dbh->methods->set_attribute) { in pdo_dbh_attribute_set()
923 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support setting attributes"); in pdo_dbh_attribute_set()
934 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
946 RETURN_BOOL(pdo_dbh_attribute_set(dbh, attr, value)); in PHP_METHOD()
953 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
966 RETURN_BOOL(dbh->is_persistent); in PHP_METHOD()
969 RETURN_LONG(dbh->desired_case); in PHP_METHOD()
972 RETURN_LONG(dbh->oracle_nulls); in PHP_METHOD()
975 RETURN_LONG(dbh->error_mode); in PHP_METHOD()
978 RETURN_STRINGL((char*)dbh->driver->driver_name, dbh->driver->driver_name_len); in PHP_METHOD()
982 add_next_index_str(return_value, zend_string_copy(dbh->def_stmt_ce->name)); in PHP_METHOD()
983 if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) { in PHP_METHOD()
984 Z_TRY_ADDREF(dbh->def_stmt_ctor_args); in PHP_METHOD()
985 add_next_index_zval(return_value, &dbh->def_stmt_ctor_args); in PHP_METHOD()
990 RETURN_LONG(dbh->default_fetch_type); in PHP_METHOD()
993 RETURN_BOOL(dbh->stringify); in PHP_METHOD()
999 if (!dbh->methods->get_attribute) { in PHP_METHOD()
1000 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support getting attributes"); in PHP_METHOD()
1004 switch (dbh->methods->get_attribute(dbh, attr, return_value)) { in PHP_METHOD()
1010 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support that attribute"); in PHP_METHOD()
1024 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1039 ret = dbh->methods->doer(dbh, statement); in PHP_METHOD()
1052 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1065 if (!dbh->methods->last_id) { in PHP_METHOD()
1066 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support lastInsertId()"); in PHP_METHOD()
1069 last_id = dbh->methods->last_id(dbh, name); in PHP_METHOD()
1081 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1087 if (dbh->query_stmt) { in PHP_METHOD()
1088 RETURN_STRING(dbh->query_stmt->error_code); in PHP_METHOD()
1091 if (dbh->error_code[0] == '\0') { in PHP_METHOD()
1099 RETURN_STRING(dbh->error_code); in PHP_METHOD()
1110 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1118 if (dbh->query_stmt) { in PHP_METHOD()
1119 add_next_index_string(return_value, dbh->query_stmt->error_code); in PHP_METHOD()
1120 if(!strncmp(dbh->query_stmt->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE))) goto fill_array; in PHP_METHOD()
1122 add_next_index_string(return_value, dbh->error_code); in PHP_METHOD()
1123 if(!strncmp(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE))) goto fill_array; in PHP_METHOD()
1126 if (dbh->methods->fetch_err) { in PHP_METHOD()
1127 dbh->methods->fetch_err(dbh, dbh->query_stmt, return_value); in PHP_METHOD()
1159 pdo_dbh_t *dbh = dbh_obj->inner; in PHP_METHOD() local
1175 if (!pdo_stmt_instantiate(dbh, return_value, dbh->def_stmt_ce, &dbh->def_stmt_ctor_args)) { in PHP_METHOD()
1183 stmt->default_fetch_type = dbh->default_fetch_type; in PHP_METHOD()
1184 stmt->dbh = dbh; in PHP_METHOD()
1190 if (dbh->methods->preparer(dbh, statement, stmt, NULL)) { in PHP_METHOD()
1198 if (stmt->dbh->alloc_own_columns) { in PHP_METHOD()
1204 if (Z_TYPE(dbh->def_stmt_ctor_args) == IS_ARRAY) { in PHP_METHOD()
1205 pdo_stmt_construct(stmt, return_value, dbh->def_stmt_ce, Z_ARRVAL(dbh->def_stmt_ctor_args)); in PHP_METHOD()
1207 pdo_stmt_construct(stmt, return_value, dbh->def_stmt_ce, /* ctor_args */ NULL); in PHP_METHOD()
1214 dbh->query_stmt = stmt; in PHP_METHOD()
1215 ZVAL_OBJ(&dbh->query_stmt_zval, Z_OBJ_P(return_value)); in PHP_METHOD()
1233 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1246 if (!dbh->methods->quoter) { in PHP_METHOD()
1247 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support quoting"); in PHP_METHOD()
1250 quoted = dbh->methods->quoter(dbh, str, paramtype); in PHP_METHOD()
1307 pdo_dbh_t *dbh = dbh_obj->inner; in pdo_hash_methods() local
1309 if (!dbh || !dbh->methods || !dbh->methods->get_driver_methods) { in pdo_hash_methods()
1312 funcs = dbh->methods->get_driver_methods(dbh, kind); in pdo_hash_methods()
1317 dbh->cls_methods[kind] = pemalloc(sizeof(HashTable), dbh->is_persistent); in pdo_hash_methods()
1318 zend_hash_init(dbh->cls_methods[kind], 8, NULL, in pdo_hash_methods()
1319 dbh->is_persistent? cls_method_pdtor : cls_method_dtor, dbh->is_persistent); in pdo_hash_methods()
1327 func.function_name = zend_string_init(funcs->fname, strlen(funcs->fname), dbh->is_persistent); in pdo_hash_methods()
1330 …ZEND_MAP_PTR(func.run_time_cache) = rt_cache_size ? pecalloc(rt_cache_size, 1, dbh->is_persistent)… in pdo_hash_methods()
1365 zend_hash_str_add_mem(dbh->cls_methods[kind], lc_name, namelen, &func, sizeof(func)); in pdo_hash_methods()
1401 pdo_dbh_t *dbh = php_pdo_dbh_fetch_inner(object); in dbh_get_gc() local
1403 zend_get_gc_buffer_add_zval(gc_buffer, &dbh->def_stmt_ctor_args); in dbh_get_gc()
1404 if (dbh->methods && dbh->methods->get_gc) { in dbh_get_gc()
1405 dbh->methods->get_gc(dbh, gc_buffer); in dbh_get_gc()
1430 static void dbh_free(pdo_dbh_t *dbh, bool free_persistent) in dbh_free() argument
1434 if (dbh->query_stmt) { in dbh_free()
1435 zval_ptr_dtor(&dbh->query_stmt_zval); in dbh_free()
1436 dbh->query_stmt = NULL; in dbh_free()
1439 if (dbh->is_persistent) { in dbh_free()
1441 ZEND_ASSERT(!free_persistent || (dbh->refcount == 1)); in dbh_free()
1443 if (!free_persistent && (--dbh->refcount)) { in dbh_free()
1448 if (dbh->methods) { in dbh_free()
1449 dbh->methods->closer(dbh); in dbh_free()
1452 if (dbh->data_source) { in dbh_free()
1453 pefree((char *)dbh->data_source, dbh->is_persistent); in dbh_free()
1455 if (dbh->username) { in dbh_free()
1456 pefree(dbh->username, dbh->is_persistent); in dbh_free()
1458 if (dbh->password) { in dbh_free()
1459 pefree(dbh->password, dbh->is_persistent); in dbh_free()
1462 if (dbh->persistent_id) { in dbh_free()
1463 pefree((char *)dbh->persistent_id, dbh->is_persistent); in dbh_free()
1466 if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) { in dbh_free()
1467 zval_ptr_dtor(&dbh->def_stmt_ctor_args); in dbh_free()
1471 if (dbh->cls_methods[i]) { in dbh_free()
1472 zend_hash_destroy(dbh->cls_methods[i]); in dbh_free()
1473 pefree(dbh->cls_methods[i], dbh->is_persistent); in dbh_free()
1477 pefree(dbh, dbh->is_persistent); in dbh_free()
1482 pdo_dbh_t *dbh = php_pdo_dbh_fetch_inner(std); in pdo_dbh_free_storage() local
1485 if (!dbh) { in pdo_dbh_free_storage()
1489 if (dbh->driver_data && dbh->methods && dbh->methods->rollback && pdo_is_in_transaction(dbh)) { in pdo_dbh_free_storage()
1490 dbh->methods->rollback(dbh); in pdo_dbh_free_storage()
1491 dbh->in_txn = false; in pdo_dbh_free_storage()
1494 if (dbh->is_persistent && dbh->methods && dbh->methods->persistent_shutdown) { in pdo_dbh_free_storage()
1495 dbh->methods->persistent_shutdown(dbh); in pdo_dbh_free_storage()
1498 dbh_free(dbh, 0); in pdo_dbh_free_storage()
1503 pdo_dbh_object_t *dbh; in pdo_dbh_new() local
1505 dbh = zend_object_alloc(sizeof(pdo_dbh_object_t), ce); in pdo_dbh_new()
1506 zend_object_std_init(&dbh->std, ce); in pdo_dbh_new()
1507 object_properties_init(&dbh->std, ce); in pdo_dbh_new()
1509 zend_std_get_properties_ex(&dbh->std); in pdo_dbh_new()
1510 dbh->inner = ecalloc(1, sizeof(pdo_dbh_t)); in pdo_dbh_new()
1511 dbh->inner->def_stmt_ce = pdo_dbstmt_ce; in pdo_dbh_new()
1513 return &dbh->std; in pdo_dbh_new()
1521 pdo_dbh_t *dbh = (pdo_dbh_t*)res->ptr; in ZEND_RSRC_DTOR_FUNC() local
1522 dbh_free(dbh, 1); in ZEND_RSRC_DTOR_FUNC()