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 && dbh->error_mode == PDO_ERRMODE_SILENT) { in pdo_raise_impl_error()
101 if (dbh && 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 == NULL || 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()
228 pdo_dbh_t *dbh = NULL; in PHP_METHOD() local
294 dbh = Z_PDO_DBH_P(object); in PHP_METHOD()
348 pdbh->def_stmt_ce = dbh->def_stmt_ce; in PHP_METHOD()
353 efree(dbh); in PHP_METHOD()
357 dbh = pdbh; in PHP_METHOD()
366 dbh->data_source_len = strlen(colon + 1); in PHP_METHOD()
367 dbh->data_source = (const char*)pestrdup(colon + 1, is_persistent); in PHP_METHOD()
368 dbh->username = username ? pestrdup(username, is_persistent) : NULL; in PHP_METHOD()
369 dbh->password = password ? pestrdup(password, is_persistent) : NULL; in PHP_METHOD()
370 dbh->default_fetch_type = PDO_FETCH_BOTH; in PHP_METHOD()
373 dbh->auto_commit = pdo_attr_lval(options, PDO_ATTR_AUTOCOMMIT, 1); in PHP_METHOD()
374 dbh->error_mode = pdo_attr_lval(options, PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION); in PHP_METHOD()
376 if (!dbh->data_source || (username && !dbh->username) || (password && !dbh->password)) { in PHP_METHOD()
389 if (driver->db_handle_factory(dbh, options)) { in PHP_METHOD()
397 (char*)dbh->persistent_id, dbh->persistent_id_len, dbh, php_pdo_list_entry())) == NULL) { in PHP_METHOD()
402 dbh->driver = driver; in PHP_METHOD()
416 pdo_dbh_attribute_set(dbh, long_key, attr_value); in PHP_METHOD()
426 dbh->refcount--; in PHP_METHOD()
437 static zval *pdo_stmt_instantiate(pdo_dbh_t *dbh, zval *object, zend_class_entry *dbstmt_ce, zval *… in pdo_stmt_instantiate() argument
504 pdo_dbh_t *dbh = dbh_obj->inner; in PHP_METHOD() local
556 dbstmt_ce = dbh->def_stmt_ce; in PHP_METHOD()
557 ZVAL_COPY_VALUE(&ctor_args, &dbh->def_stmt_ctor_args); in PHP_METHOD()
560 if (!pdo_stmt_instantiate(dbh, return_value, dbstmt_ce, &ctor_args)) { in PHP_METHOD()
567 stmt->default_fetch_type = dbh->default_fetch_type; in PHP_METHOD()
568 stmt->dbh = dbh; in PHP_METHOD()
574 if (dbh->methods->preparer(dbh, statement, stmt, options)) { in PHP_METHOD()
589 static bool pdo_is_in_transaction(pdo_dbh_t *dbh) { in pdo_is_in_transaction() argument
590 if (dbh->methods->in_transaction) { in pdo_is_in_transaction()
591 return dbh->methods->in_transaction(dbh); in pdo_is_in_transaction()
593 return dbh->in_txn; in pdo_is_in_transaction()
599 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
605 if (pdo_is_in_transaction(dbh)) { in PHP_METHOD()
610 if (!dbh->methods->begin) { in PHP_METHOD()
616 if (dbh->methods->begin(dbh)) { in PHP_METHOD()
617 dbh->in_txn = true; in PHP_METHOD()
629 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
635 if (!pdo_is_in_transaction(dbh)) { in PHP_METHOD()
640 if (dbh->methods->commit(dbh)) { in PHP_METHOD()
641 dbh->in_txn = false; in PHP_METHOD()
653 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
659 if (!pdo_is_in_transaction(dbh)) { in PHP_METHOD()
664 if (dbh->methods->rollback(dbh)) { in PHP_METHOD()
665 dbh->in_txn = false; in PHP_METHOD()
677 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
683 RETURN_BOOL(pdo_is_in_transaction(dbh)); in PHP_METHOD()
725 static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /* {{{ */ in pdo_dbh_attribute_set() argument
739 dbh->error_mode = lval; in pdo_dbh_attribute_set()
755 dbh->desired_case = lval; in pdo_dbh_attribute_set()
768 dbh->oracle_nulls = lval; in pdo_dbh_attribute_set()
790 dbh->default_fetch_type = lval; in pdo_dbh_attribute_set()
797 dbh->stringify = bval; in pdo_dbh_attribute_set()
798 if (dbh->methods->set_attribute) { in pdo_dbh_attribute_set()
799 dbh->methods->set_attribute(dbh, attr, value); in pdo_dbh_attribute_set()
808 if (dbh->is_persistent) { in pdo_dbh_attribute_set()
810 pdo_raise_impl_error(dbh, NULL, "HY000", in pdo_dbh_attribute_set()
838 dbh->def_stmt_ce = pce; in pdo_dbh_attribute_set()
839 if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) { in pdo_dbh_attribute_set()
840 zval_ptr_dtor(&dbh->def_stmt_ctor_args); in pdo_dbh_attribute_set()
841 ZVAL_UNDEF(&dbh->def_stmt_ctor_args); in pdo_dbh_attribute_set()
849 ZVAL_COPY(&dbh->def_stmt_ctor_args, item); in pdo_dbh_attribute_set()
857 if (!dbh->methods->set_attribute) { in pdo_dbh_attribute_set()
862 if (dbh->methods->set_attribute(dbh, attr, value)) { in pdo_dbh_attribute_set()
867 if (!dbh->methods->set_attribute) { in pdo_dbh_attribute_set()
868 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support setting attributes"); in pdo_dbh_attribute_set()
879 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
891 RETURN_BOOL(pdo_dbh_attribute_set(dbh, attr, value)); in PHP_METHOD()
898 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
911 RETURN_BOOL(dbh->is_persistent); in PHP_METHOD()
914 RETURN_LONG(dbh->desired_case); in PHP_METHOD()
917 RETURN_LONG(dbh->oracle_nulls); in PHP_METHOD()
920 RETURN_LONG(dbh->error_mode); in PHP_METHOD()
923 RETURN_STRINGL((char*)dbh->driver->driver_name, dbh->driver->driver_name_len); in PHP_METHOD()
927 add_next_index_str(return_value, zend_string_copy(dbh->def_stmt_ce->name)); in PHP_METHOD()
928 if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) { in PHP_METHOD()
929 Z_TRY_ADDREF(dbh->def_stmt_ctor_args); in PHP_METHOD()
930 add_next_index_zval(return_value, &dbh->def_stmt_ctor_args); in PHP_METHOD()
935 RETURN_LONG(dbh->default_fetch_type); in PHP_METHOD()
938 RETURN_BOOL(dbh->stringify); in PHP_METHOD()
944 if (!dbh->methods->get_attribute) { in PHP_METHOD()
945 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support getting attributes"); in PHP_METHOD()
949 switch (dbh->methods->get_attribute(dbh, attr, return_value)) { in PHP_METHOD()
955 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support that attribute"); in PHP_METHOD()
969 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
984 ret = dbh->methods->doer(dbh, statement); in PHP_METHOD()
997 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1010 if (!dbh->methods->last_id) { in PHP_METHOD()
1011 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support lastInsertId()"); in PHP_METHOD()
1014 last_id = dbh->methods->last_id(dbh, name); in PHP_METHOD()
1026 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1032 if (dbh->query_stmt) { in PHP_METHOD()
1033 RETURN_STRING(dbh->query_stmt->error_code); in PHP_METHOD()
1036 if (dbh->error_code[0] == '\0') { in PHP_METHOD()
1044 RETURN_STRING(dbh->error_code); in PHP_METHOD()
1055 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1063 if (dbh->query_stmt) { in PHP_METHOD()
1064 add_next_index_string(return_value, dbh->query_stmt->error_code); in PHP_METHOD()
1065 if(!strncmp(dbh->query_stmt->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE))) goto fill_array; in PHP_METHOD()
1067 add_next_index_string(return_value, dbh->error_code); in PHP_METHOD()
1068 if(!strncmp(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE))) goto fill_array; in PHP_METHOD()
1071 if (dbh->methods->fetch_err) { in PHP_METHOD()
1072 dbh->methods->fetch_err(dbh, dbh->query_stmt, return_value); in PHP_METHOD()
1104 pdo_dbh_t *dbh = dbh_obj->inner; in PHP_METHOD() local
1120 if (!pdo_stmt_instantiate(dbh, return_value, dbh->def_stmt_ce, &dbh->def_stmt_ctor_args)) { in PHP_METHOD()
1128 stmt->default_fetch_type = dbh->default_fetch_type; in PHP_METHOD()
1129 stmt->dbh = dbh; in PHP_METHOD()
1135 if (dbh->methods->preparer(dbh, statement, stmt, NULL)) { in PHP_METHOD()
1143 if (stmt->dbh->alloc_own_columns) { in PHP_METHOD()
1149 … pdo_stmt_construct(execute_data, stmt, return_value, dbh->def_stmt_ce, &dbh->def_stmt_ctor_args); in PHP_METHOD()
1155 dbh->query_stmt = stmt; in PHP_METHOD()
1156 ZVAL_OBJ(&dbh->query_stmt_zval, Z_OBJ_P(return_value)); in PHP_METHOD()
1174 pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS); in PHP_METHOD() local
1187 if (!dbh->methods->quoter) { in PHP_METHOD()
1188 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support quoting"); in PHP_METHOD()
1191 quoted = dbh->methods->quoter(dbh, str, paramtype); in PHP_METHOD()
1248 pdo_dbh_t *dbh = dbh_obj->inner; in pdo_hash_methods() local
1250 if (!dbh || !dbh->methods || !dbh->methods->get_driver_methods) { in pdo_hash_methods()
1253 funcs = dbh->methods->get_driver_methods(dbh, kind); in pdo_hash_methods()
1258 dbh->cls_methods[kind] = pemalloc(sizeof(HashTable), dbh->is_persistent); in pdo_hash_methods()
1259 zend_hash_init(dbh->cls_methods[kind], 8, NULL, in pdo_hash_methods()
1260 dbh->is_persistent? cls_method_pdtor : cls_method_dtor, dbh->is_persistent); in pdo_hash_methods()
1268 func.function_name = zend_string_init(funcs->fname, strlen(funcs->fname), dbh->is_persistent); in pdo_hash_methods()
1271 …ZEND_MAP_PTR(func.run_time_cache) = rt_cache_size ? pecalloc(rt_cache_size, 1, dbh->is_persistent)… in pdo_hash_methods()
1305 zend_hash_str_add_mem(dbh->cls_methods[kind], lc_name, namelen, &func, sizeof(func)); in pdo_hash_methods()
1341 pdo_dbh_t *dbh = php_pdo_dbh_fetch_inner(object); in dbh_get_gc() local
1343 zend_get_gc_buffer_add_zval(gc_buffer, &dbh->def_stmt_ctor_args); in dbh_get_gc()
1344 if (dbh->methods && dbh->methods->get_gc) { in dbh_get_gc()
1345 dbh->methods->get_gc(dbh, gc_buffer); in dbh_get_gc()
1369 static void dbh_free(pdo_dbh_t *dbh, bool free_persistent) in dbh_free() argument
1373 if (dbh->query_stmt) { in dbh_free()
1374 zval_ptr_dtor(&dbh->query_stmt_zval); in dbh_free()
1375 dbh->query_stmt = NULL; in dbh_free()
1378 if (dbh->is_persistent) { in dbh_free()
1380 ZEND_ASSERT(!free_persistent || (dbh->refcount == 1)); in dbh_free()
1382 if (!free_persistent && (--dbh->refcount)) { in dbh_free()
1387 if (dbh->methods) { in dbh_free()
1388 dbh->methods->closer(dbh); in dbh_free()
1391 if (dbh->data_source) { in dbh_free()
1392 pefree((char *)dbh->data_source, dbh->is_persistent); in dbh_free()
1394 if (dbh->username) { in dbh_free()
1395 pefree(dbh->username, dbh->is_persistent); in dbh_free()
1397 if (dbh->password) { in dbh_free()
1398 pefree(dbh->password, dbh->is_persistent); in dbh_free()
1401 if (dbh->persistent_id) { in dbh_free()
1402 pefree((char *)dbh->persistent_id, dbh->is_persistent); in dbh_free()
1405 if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) { in dbh_free()
1406 zval_ptr_dtor(&dbh->def_stmt_ctor_args); in dbh_free()
1410 if (dbh->cls_methods[i]) { in dbh_free()
1411 zend_hash_destroy(dbh->cls_methods[i]); in dbh_free()
1412 pefree(dbh->cls_methods[i], dbh->is_persistent); in dbh_free()
1416 pefree(dbh, dbh->is_persistent); in dbh_free()
1421 pdo_dbh_t *dbh = php_pdo_dbh_fetch_inner(std); in pdo_dbh_free_storage() local
1424 if (!dbh) { in pdo_dbh_free_storage()
1428 if (dbh->driver_data && dbh->methods && dbh->methods->rollback && pdo_is_in_transaction(dbh)) { in pdo_dbh_free_storage()
1429 dbh->methods->rollback(dbh); in pdo_dbh_free_storage()
1430 dbh->in_txn = false; in pdo_dbh_free_storage()
1433 if (dbh->is_persistent && dbh->methods && dbh->methods->persistent_shutdown) { in pdo_dbh_free_storage()
1434 dbh->methods->persistent_shutdown(dbh); in pdo_dbh_free_storage()
1437 dbh_free(dbh, 0); in pdo_dbh_free_storage()
1442 pdo_dbh_object_t *dbh; in pdo_dbh_new() local
1444 dbh = zend_object_alloc(sizeof(pdo_dbh_object_t), ce); in pdo_dbh_new()
1445 zend_object_std_init(&dbh->std, ce); in pdo_dbh_new()
1446 object_properties_init(&dbh->std, ce); in pdo_dbh_new()
1447 rebuild_object_properties(&dbh->std); in pdo_dbh_new()
1448 dbh->inner = ecalloc(1, sizeof(pdo_dbh_t)); in pdo_dbh_new()
1449 dbh->inner->def_stmt_ce = pdo_dbstmt_ce; in pdo_dbh_new()
1451 return &dbh->std; in pdo_dbh_new()
1459 pdo_dbh_t *dbh = (pdo_dbh_t*)res->ptr; in ZEND_RSRC_DTOR_FUNC() local
1460 dbh_free(dbh, 1); in ZEND_RSRC_DTOR_FUNC()