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()
303 pdo_dbh_t *dbh = NULL; in php_pdo_internal_construct_driver() local
376 dbh = Z_PDO_DBH_P(new_zval_object); in php_pdo_internal_construct_driver()
378 dbh = php_pdo_dbh_fetch_inner(current_object); in php_pdo_internal_construct_driver()
433 pdbh->def_stmt_ce = dbh->def_stmt_ce; in php_pdo_internal_construct_driver()
438 efree(dbh); in php_pdo_internal_construct_driver()
450 dbh = pdbh; in php_pdo_internal_construct_driver()
459 dbh->data_source_len = strlen(colon + 1); in php_pdo_internal_construct_driver()
460 dbh->data_source = (const char*)pestrdup(colon + 1, is_persistent); in php_pdo_internal_construct_driver()
461 dbh->username = username ? pestrdup(username, is_persistent) : NULL; in php_pdo_internal_construct_driver()
462 dbh->password = password ? pestrdup(password, is_persistent) : NULL; in php_pdo_internal_construct_driver()
463 dbh->default_fetch_type = PDO_FETCH_BOTH; in php_pdo_internal_construct_driver()
466 dbh->auto_commit = pdo_attr_lval(options, PDO_ATTR_AUTOCOMMIT, 1); in php_pdo_internal_construct_driver()
467 dbh->error_mode = pdo_attr_lval(options, PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION); in php_pdo_internal_construct_driver()
469 if (!dbh->data_source || (username && !dbh->username) || (password && !dbh->password)) { in php_pdo_internal_construct_driver()
482 if (driver->db_handle_factory(dbh, options)) { in php_pdo_internal_construct_driver()
490 (char*)dbh->persistent_id, dbh->persistent_id_len, dbh, php_pdo_list_entry())) == NULL) { in php_pdo_internal_construct_driver()
495 dbh->driver = driver; in php_pdo_internal_construct_driver()
509 pdo_dbh_attribute_set(dbh, long_key, attr_value); in php_pdo_internal_construct_driver()
519 dbh->refcount--; in php_pdo_internal_construct_driver()
543 static zval *pdo_stmt_instantiate(pdo_dbh_t *dbh, zval *object, zend_class_entry *dbstmt_ce, zval *… in pdo_stmt_instantiate() argument
587 pdo_dbh_t *dbh = dbh_obj->inner; in PHP_METHOD() local
639 dbstmt_ce = dbh->def_stmt_ce; in PHP_METHOD()
640 ZVAL_COPY_VALUE(&ctor_args, &dbh->def_stmt_ctor_args); in PHP_METHOD()
643 if (!pdo_stmt_instantiate(dbh, return_value, dbstmt_ce, &ctor_args)) { in PHP_METHOD()
650 stmt->default_fetch_type = dbh->default_fetch_type; in PHP_METHOD()
651 stmt->dbh = dbh; in PHP_METHOD()
657 if (dbh->methods->preparer(dbh, statement, stmt, options)) { in PHP_METHOD()
676 static bool pdo_is_in_transaction(pdo_dbh_t *dbh) { in pdo_is_in_transaction() argument
677 if (dbh->methods->in_transaction) { in pdo_is_in_transaction()
678 return dbh->methods->in_transaction(dbh); in pdo_is_in_transaction()
680 return dbh->in_txn; in pdo_is_in_transaction()
686 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
692 if (pdo_is_in_transaction(dbh)) { in PHP_METHOD()
697 if (!dbh->methods->begin) { in PHP_METHOD()
703 if (dbh->methods->begin(dbh)) { in PHP_METHOD()
704 dbh->in_txn = true; in PHP_METHOD()
716 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
722 if (!pdo_is_in_transaction(dbh)) { in PHP_METHOD()
727 if (dbh->methods->commit(dbh)) { in PHP_METHOD()
728 dbh->in_txn = false; in PHP_METHOD()
740 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
746 if (!pdo_is_in_transaction(dbh)) { in PHP_METHOD()
751 if (dbh->methods->rollback(dbh)) { in PHP_METHOD()
752 dbh->in_txn = false; in PHP_METHOD()
764 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
770 RETURN_BOOL(pdo_is_in_transaction(dbh)); in PHP_METHOD()
812 static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /* {{{ */ in pdo_dbh_attribute_set() argument
826 dbh->error_mode = lval; in pdo_dbh_attribute_set()
842 dbh->desired_case = lval; in pdo_dbh_attribute_set()
855 dbh->oracle_nulls = lval; in pdo_dbh_attribute_set()
877 dbh->default_fetch_type = lval; in pdo_dbh_attribute_set()
884 dbh->stringify = bval; in pdo_dbh_attribute_set()
885 if (dbh->methods->set_attribute) { in pdo_dbh_attribute_set()
886 dbh->methods->set_attribute(dbh, attr, value); in pdo_dbh_attribute_set()
895 if (dbh->is_persistent) { in pdo_dbh_attribute_set()
897 pdo_raise_impl_error(dbh, NULL, "HY000", in pdo_dbh_attribute_set()
925 dbh->def_stmt_ce = pce; in pdo_dbh_attribute_set()
926 if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) { in pdo_dbh_attribute_set()
927 zval_ptr_dtor(&dbh->def_stmt_ctor_args); in pdo_dbh_attribute_set()
928 ZVAL_UNDEF(&dbh->def_stmt_ctor_args); in pdo_dbh_attribute_set()
936 ZVAL_COPY(&dbh->def_stmt_ctor_args, item); in pdo_dbh_attribute_set()
944 if (!dbh->methods->set_attribute) { in pdo_dbh_attribute_set()
949 if (dbh->methods->set_attribute(dbh, attr, value)) { in pdo_dbh_attribute_set()
954 if (!dbh->methods->set_attribute) { in pdo_dbh_attribute_set()
955 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support setting attributes"); in pdo_dbh_attribute_set()
966 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
978 RETURN_BOOL(pdo_dbh_attribute_set(dbh, attr, value)); in PHP_METHOD()
985 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
998 RETURN_BOOL(dbh->is_persistent); in PHP_METHOD()
1001 RETURN_LONG(dbh->desired_case); in PHP_METHOD()
1004 RETURN_LONG(dbh->oracle_nulls); in PHP_METHOD()
1007 RETURN_LONG(dbh->error_mode); in PHP_METHOD()
1010 RETURN_STRINGL((char*)dbh->driver->driver_name, dbh->driver->driver_name_len); in PHP_METHOD()
1014 add_next_index_str(return_value, zend_string_copy(dbh->def_stmt_ce->name)); in PHP_METHOD()
1015 if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) { in PHP_METHOD()
1016 Z_TRY_ADDREF(dbh->def_stmt_ctor_args); in PHP_METHOD()
1017 add_next_index_zval(return_value, &dbh->def_stmt_ctor_args); in PHP_METHOD()
1022 RETURN_LONG(dbh->default_fetch_type); in PHP_METHOD()
1025 RETURN_BOOL(dbh->stringify); in PHP_METHOD()
1031 if (!dbh->methods->get_attribute) { in PHP_METHOD()
1032 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support getting attributes"); in PHP_METHOD()
1036 switch (dbh->methods->get_attribute(dbh, attr, return_value)) { in PHP_METHOD()
1042 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support that attribute"); in PHP_METHOD()
1056 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1071 ret = dbh->methods->doer(dbh, statement); in PHP_METHOD()
1084 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1097 if (!dbh->methods->last_id) { in PHP_METHOD()
1098 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support lastInsertId()"); in PHP_METHOD()
1101 last_id = dbh->methods->last_id(dbh, name); in PHP_METHOD()
1113 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1119 if (dbh->query_stmt) { in PHP_METHOD()
1120 RETURN_STRING(dbh->query_stmt->error_code); in PHP_METHOD()
1123 if (dbh->error_code[0] == '\0') { in PHP_METHOD()
1131 RETURN_STRING(dbh->error_code); in PHP_METHOD()
1142 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1150 if (dbh->query_stmt) { in PHP_METHOD()
1151 add_next_index_string(return_value, dbh->query_stmt->error_code); in PHP_METHOD()
1152 if(!strncmp(dbh->query_stmt->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE))) goto fill_array; in PHP_METHOD()
1154 add_next_index_string(return_value, dbh->error_code); in PHP_METHOD()
1155 if(!strncmp(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE))) goto fill_array; in PHP_METHOD()
1158 if (dbh->methods->fetch_err) { in PHP_METHOD()
1159 dbh->methods->fetch_err(dbh, dbh->query_stmt, return_value); in PHP_METHOD()
1191 pdo_dbh_t *dbh = dbh_obj->inner; in PHP_METHOD() local
1207 if (!pdo_stmt_instantiate(dbh, return_value, dbh->def_stmt_ce, &dbh->def_stmt_ctor_args)) { in PHP_METHOD()
1215 stmt->default_fetch_type = dbh->default_fetch_type; in PHP_METHOD()
1216 stmt->dbh = dbh; in PHP_METHOD()
1222 if (dbh->methods->preparer(dbh, statement, stmt, NULL)) { in PHP_METHOD()
1230 if (stmt->dbh->alloc_own_columns) { in PHP_METHOD()
1236 if (Z_TYPE(dbh->def_stmt_ctor_args) == IS_ARRAY) { in PHP_METHOD()
1237 pdo_stmt_construct(stmt, return_value, dbh->def_stmt_ce, Z_ARRVAL(dbh->def_stmt_ctor_args)); in PHP_METHOD()
1239 pdo_stmt_construct(stmt, return_value, dbh->def_stmt_ce, /* ctor_args */ NULL); in PHP_METHOD()
1246 dbh->query_stmt = stmt; in PHP_METHOD()
1247 ZVAL_OBJ(&dbh->query_stmt_zval, Z_OBJ_P(return_value)); in PHP_METHOD()
1265 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1278 if (!dbh->methods->quoter) { in PHP_METHOD()
1279 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support quoting"); in PHP_METHOD()
1282 quoted = dbh->methods->quoter(dbh, str, paramtype); in PHP_METHOD()
1339 pdo_dbh_t *dbh = dbh_obj->inner; in pdo_hash_methods() local
1341 if (!dbh || !dbh->methods || !dbh->methods->get_driver_methods) { in pdo_hash_methods()
1344 funcs = dbh->methods->get_driver_methods(dbh, kind); in pdo_hash_methods()
1349 dbh->cls_methods[kind] = pemalloc(sizeof(HashTable), dbh->is_persistent); in pdo_hash_methods()
1350 zend_hash_init(dbh->cls_methods[kind], 8, NULL, in pdo_hash_methods()
1351 dbh->is_persistent? cls_method_pdtor : cls_method_dtor, dbh->is_persistent); in pdo_hash_methods()
1359 func.function_name = zend_string_init(funcs->fname, strlen(funcs->fname), dbh->is_persistent); in pdo_hash_methods()
1362 …ZEND_MAP_PTR(func.run_time_cache) = rt_cache_size ? pecalloc(rt_cache_size, 1, dbh->is_persistent)… in pdo_hash_methods()
1397 zend_hash_str_add_mem(dbh->cls_methods[kind], lc_name, namelen, &func, sizeof(func)); in pdo_hash_methods()
1433 pdo_dbh_t *dbh = php_pdo_dbh_fetch_inner(object); in dbh_get_gc() local
1435 zend_get_gc_buffer_add_zval(gc_buffer, &dbh->def_stmt_ctor_args); in dbh_get_gc()
1436 if (dbh->methods && dbh->methods->get_gc) { in dbh_get_gc()
1437 dbh->methods->get_gc(dbh, gc_buffer); in dbh_get_gc()
1462 static void dbh_free(pdo_dbh_t *dbh, bool free_persistent) in dbh_free() argument
1466 if (dbh->query_stmt) { in dbh_free()
1467 zval_ptr_dtor(&dbh->query_stmt_zval); in dbh_free()
1468 dbh->query_stmt = NULL; in dbh_free()
1471 if (dbh->is_persistent) { in dbh_free()
1473 ZEND_ASSERT(!free_persistent || (dbh->refcount == 1)); in dbh_free()
1475 if (!free_persistent && (--dbh->refcount)) { in dbh_free()
1480 if (dbh->methods) { in dbh_free()
1481 dbh->methods->closer(dbh); in dbh_free()
1484 if (dbh->data_source) { in dbh_free()
1485 pefree((char *)dbh->data_source, dbh->is_persistent); in dbh_free()
1487 if (dbh->username) { in dbh_free()
1488 pefree(dbh->username, dbh->is_persistent); in dbh_free()
1490 if (dbh->password) { in dbh_free()
1491 pefree(dbh->password, dbh->is_persistent); in dbh_free()
1494 if (dbh->persistent_id) { in dbh_free()
1495 pefree((char *)dbh->persistent_id, dbh->is_persistent); in dbh_free()
1498 if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) { in dbh_free()
1499 zval_ptr_dtor(&dbh->def_stmt_ctor_args); in dbh_free()
1503 if (dbh->cls_methods[i]) { in dbh_free()
1504 zend_hash_destroy(dbh->cls_methods[i]); in dbh_free()
1505 pefree(dbh->cls_methods[i], dbh->is_persistent); in dbh_free()
1509 pefree(dbh, dbh->is_persistent); in dbh_free()
1514 pdo_dbh_t *dbh = php_pdo_dbh_fetch_inner(std); in pdo_dbh_free_storage() local
1517 if (!dbh) { in pdo_dbh_free_storage()
1521 if (dbh->driver_data && dbh->methods && dbh->methods->rollback && pdo_is_in_transaction(dbh)) { in pdo_dbh_free_storage()
1522 dbh->methods->rollback(dbh); in pdo_dbh_free_storage()
1523 dbh->in_txn = false; in pdo_dbh_free_storage()
1526 if (dbh->is_persistent && dbh->methods && dbh->methods->persistent_shutdown) { in pdo_dbh_free_storage()
1527 dbh->methods->persistent_shutdown(dbh); in pdo_dbh_free_storage()
1530 dbh_free(dbh, 0); in pdo_dbh_free_storage()
1535 pdo_dbh_object_t *dbh; in pdo_dbh_new() local
1537 dbh = zend_object_alloc(sizeof(pdo_dbh_object_t), ce); in pdo_dbh_new()
1538 zend_object_std_init(&dbh->std, ce); in pdo_dbh_new()
1539 object_properties_init(&dbh->std, ce); in pdo_dbh_new()
1541 zend_std_get_properties_ex(&dbh->std); in pdo_dbh_new()
1542 dbh->inner = ecalloc(1, sizeof(pdo_dbh_t)); in pdo_dbh_new()
1543 dbh->inner->def_stmt_ce = pdo_dbstmt_ce; in pdo_dbh_new()
1545 return &dbh->std; in pdo_dbh_new()
1553 pdo_dbh_t *dbh = (pdo_dbh_t*)res->ptr; in ZEND_RSRC_DTOR_FUNC() local
1554 dbh_free(dbh, 1); in ZEND_RSRC_DTOR_FUNC()