Lines Matching refs:dbh

37 static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value);
66 void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate, const char *supp)… in pdo_raise_impl_error() argument
68 pdo_error_type *pdo_err = &dbh->error_code; in pdo_raise_impl_error()
72 if (dbh && dbh->error_mode == PDO_ERRMODE_SILENT) { in pdo_raise_impl_error()
99 if (dbh && dbh->error_mode != PDO_ERRMODE_EXCEPTION) { in pdo_raise_impl_error()
126 PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt) /* {{{ */ in pdo_handle_error() argument
128 pdo_error_type *pdo_err = &dbh->error_code; in pdo_handle_error()
135 if (dbh == NULL || dbh->error_mode == PDO_ERRMODE_SILENT) { in pdo_handle_error()
150 if (dbh->methods->fetch_err) { in pdo_handle_error()
155 if (dbh->methods->fetch_err(dbh, stmt, &info)) { in pdo_handle_error()
174 if (dbh->error_mode == PDO_ERRMODE_WARNING) { in pdo_handle_error()
225 pdo_dbh_t *dbh = NULL; in PHP_METHOD() local
291 dbh = Z_PDO_DBH_P(object); in PHP_METHOD()
345 pdbh->def_stmt_ce = dbh->def_stmt_ce; in PHP_METHOD()
350 efree(dbh); in PHP_METHOD()
354 dbh = pdbh; in PHP_METHOD()
363 dbh->data_source_len = strlen(colon + 1); in PHP_METHOD()
364 dbh->data_source = (const char*)pestrdup(colon + 1, is_persistent); in PHP_METHOD()
365 dbh->username = username ? pestrdup(username, is_persistent) : NULL; in PHP_METHOD()
366 dbh->password = password ? pestrdup(password, is_persistent) : NULL; in PHP_METHOD()
367 dbh->default_fetch_type = PDO_FETCH_BOTH; in PHP_METHOD()
370 dbh->auto_commit = pdo_attr_lval(options, PDO_ATTR_AUTOCOMMIT, 1); in PHP_METHOD()
372 if (!dbh->data_source || (username && !dbh->username) || (password && !dbh->password)) { in PHP_METHOD()
383 if (driver->db_handle_factory(dbh, options)) { in PHP_METHOD()
391 (char*)dbh->persistent_id, dbh->persistent_id_len, dbh, php_pdo_list_entry())) == NULL) { in PHP_METHOD()
396 dbh->driver = driver; in PHP_METHOD()
408 pdo_dbh_attribute_set(dbh, long_key, attr_value); in PHP_METHOD()
425 static zval *pdo_stmt_instantiate(pdo_dbh_t *dbh, zval *object, zend_class_entry *dbstmt_ce, zval *… in pdo_stmt_instantiate() argument
429 pdo_raise_impl_error(dbh, NULL, "HY000", "constructor arguments must be passed as an array"); in pdo_stmt_instantiate()
433 …pdo_raise_impl_error(dbh, NULL, "HY000", "user-supplied statement does not accept constructor argu… in pdo_stmt_instantiate()
494 pdo_dbh_t *dbh = dbh_obj->inner; in PHP_METHOD() local
510 pdo_raise_impl_error(dbh, NULL, "HY000", in PHP_METHOD()
519 pdo_raise_impl_error(dbh, NULL, "HY000", in PHP_METHOD()
525 pdo_raise_impl_error(dbh, NULL, "HY000", in PHP_METHOD()
532 pdo_raise_impl_error(dbh, NULL, "HY000", in PHP_METHOD()
544 dbstmt_ce = dbh->def_stmt_ce; in PHP_METHOD()
545 ZVAL_COPY_VALUE(&ctor_args, &dbh->def_stmt_ctor_args); in PHP_METHOD()
548 if (!pdo_stmt_instantiate(dbh, return_value, dbstmt_ce, &ctor_args)) { in PHP_METHOD()
550 pdo_raise_impl_error(dbh, NULL, "HY000", in PHP_METHOD()
562 stmt->default_fetch_type = dbh->default_fetch_type; in PHP_METHOD()
563 stmt->dbh = dbh; in PHP_METHOD()
570 if (dbh->methods->preparer(dbh, statement, statement_len, stmt, options)) { in PHP_METHOD()
588 pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis()); in PHP_METHOD() local
595 if (dbh->in_txn) { in PHP_METHOD()
600 if (!dbh->methods->begin) { in PHP_METHOD()
607 if (dbh->methods->begin(dbh)) { in PHP_METHOD()
608 dbh->in_txn = 1; in PHP_METHOD()
621 pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis()); in PHP_METHOD() local
628 if (!dbh->in_txn) { in PHP_METHOD()
633 if (dbh->methods->commit(dbh)) { in PHP_METHOD()
634 dbh->in_txn = 0; in PHP_METHOD()
647 pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis()); in PHP_METHOD() local
654 if (!dbh->in_txn) { in PHP_METHOD()
659 if (dbh->methods->rollback(dbh)) { in PHP_METHOD()
660 dbh->in_txn = 0; in PHP_METHOD()
673 pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis()); in PHP_METHOD() local
680 if (!dbh->methods->in_transaction) { in PHP_METHOD()
681 RETURN_BOOL(dbh->in_txn); in PHP_METHOD()
684 RETURN_BOOL(dbh->methods->in_transaction(dbh)); in PHP_METHOD()
688 static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /* {{{ */ in pdo_dbh_attribute_set() argument
694 pdo_raise_impl_error(dbh, NULL, "HY000", "attribute value must be an integer"); \ in pdo_dbh_attribute_set()
707 dbh->error_mode = lval; in pdo_dbh_attribute_set()
710 pdo_raise_impl_error(dbh, NULL, "HY000", "invalid error mode"); in pdo_dbh_attribute_set()
723 dbh->desired_case = lval; in pdo_dbh_attribute_set()
726 pdo_raise_impl_error(dbh, NULL, "HY000", "invalid case folding mode"); in pdo_dbh_attribute_set()
734 dbh->oracle_nulls = zval_get_long(value); in pdo_dbh_attribute_set()
742 …pdo_raise_impl_error(dbh, NULL, "HY000", "FETCH_INTO and FETCH_CLASS are not yet supported as defa… in pdo_dbh_attribute_set()
751 pdo_raise_impl_error(dbh, NULL, "HY000", "invalid fetch mode type"); in pdo_dbh_attribute_set()
754 dbh->default_fetch_type = lval; in pdo_dbh_attribute_set()
759 dbh->stringify = zval_get_long(value) ? 1 : 0; in pdo_dbh_attribute_set()
767 if (dbh->is_persistent) { in pdo_dbh_attribute_set()
768 pdo_raise_impl_error(dbh, NULL, "HY000", in pdo_dbh_attribute_set()
779 pdo_raise_impl_error(dbh, NULL, "HY000", in pdo_dbh_attribute_set()
787 pdo_raise_impl_error(dbh, NULL, "HY000", in pdo_dbh_attribute_set()
793 pdo_raise_impl_error(dbh, NULL, "HY000", in pdo_dbh_attribute_set()
798 dbh->def_stmt_ce = pce; in pdo_dbh_attribute_set()
799 if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) { in pdo_dbh_attribute_set()
800 zval_ptr_dtor(&dbh->def_stmt_ctor_args); in pdo_dbh_attribute_set()
801 ZVAL_UNDEF(&dbh->def_stmt_ctor_args); in pdo_dbh_attribute_set()
805 pdo_raise_impl_error(dbh, NULL, "HY000", in pdo_dbh_attribute_set()
812 ZVAL_COPY(&dbh->def_stmt_ctor_args, item); in pdo_dbh_attribute_set()
821 if (!dbh->methods->set_attribute) { in pdo_dbh_attribute_set()
826 if (dbh->methods->set_attribute(dbh, attr, value)) { in pdo_dbh_attribute_set()
833 } else if (!dbh->methods->set_attribute) { in pdo_dbh_attribute_set()
834 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support setting attributes"); in pdo_dbh_attribute_set()
846 pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis()); in PHP_METHOD() local
858 if (pdo_dbh_attribute_set(dbh, attr, value) != FAILURE) { in PHP_METHOD()
869 pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis()); in PHP_METHOD() local
882 RETURN_BOOL(dbh->is_persistent); in PHP_METHOD()
885 RETURN_LONG(dbh->desired_case); in PHP_METHOD()
888 RETURN_LONG(dbh->oracle_nulls); in PHP_METHOD()
891 RETURN_LONG(dbh->error_mode); in PHP_METHOD()
894 RETURN_STRINGL((char*)dbh->driver->driver_name, dbh->driver->driver_name_len); in PHP_METHOD()
898 add_next_index_str(return_value, zend_string_copy(dbh->def_stmt_ce->name)); in PHP_METHOD()
899 if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) { in PHP_METHOD()
900 Z_TRY_ADDREF(dbh->def_stmt_ctor_args); in PHP_METHOD()
901 add_next_index_zval(return_value, &dbh->def_stmt_ctor_args); in PHP_METHOD()
905 RETURN_LONG(dbh->default_fetch_type); in PHP_METHOD()
910 if (!dbh->methods->get_attribute) { in PHP_METHOD()
911 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support getting attributes"); in PHP_METHOD()
915 switch (dbh->methods->get_attribute(dbh, attr, return_value)) { in PHP_METHOD()
921 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support that attribute"); in PHP_METHOD()
934 pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis()); in PHP_METHOD() local
944 pdo_raise_impl_error(dbh, NULL, "HY000", "trying to execute an empty query"); in PHP_METHOD()
949 ret = dbh->methods->doer(dbh, statement, statement_len); in PHP_METHOD()
963 pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis()); in PHP_METHOD() local
974 if (!dbh->methods->last_id) { in PHP_METHOD()
975 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support lastInsertId()"); in PHP_METHOD()
980 id = dbh->methods->last_id(dbh, name, &id_len); in PHP_METHOD()
997 pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis()); in PHP_METHOD() local
1004 if (dbh->query_stmt) { in PHP_METHOD()
1005 RETURN_STRING(dbh->query_stmt->error_code); in PHP_METHOD()
1008 if (dbh->error_code[0] == '\0') { in PHP_METHOD()
1016 RETURN_STRING(dbh->error_code); in PHP_METHOD()
1028 pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis()); in PHP_METHOD() local
1038 if (dbh->query_stmt) { in PHP_METHOD()
1039 add_next_index_string(return_value, dbh->query_stmt->error_code); in PHP_METHOD()
1040 if(!strncmp(dbh->query_stmt->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE))) goto fill_array; in PHP_METHOD()
1042 add_next_index_string(return_value, dbh->error_code); in PHP_METHOD()
1043 if(!strncmp(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE))) goto fill_array; in PHP_METHOD()
1046 if (dbh->methods->fetch_err) { in PHP_METHOD()
1047 dbh->methods->fetch_err(dbh, dbh->query_stmt, return_value); in PHP_METHOD()
1077 pdo_dbh_t *dbh = dbh_obj->inner; in PHP_METHOD() local
1093 if (!pdo_stmt_instantiate(dbh, return_value, dbh->def_stmt_ce, &dbh->def_stmt_ctor_args)) { in PHP_METHOD()
1095 pdo_raise_impl_error(dbh, NULL, "HY000", "failed to instantiate user supplied statement class"); in PHP_METHOD()
1105 stmt->default_fetch_type = dbh->default_fetch_type; in PHP_METHOD()
1108 stmt->dbh = dbh; in PHP_METHOD()
1115 if (dbh->methods->preparer(dbh, statement, statement_len, stmt, NULL)) { in PHP_METHOD()
1124 if (stmt->dbh->alloc_own_columns) { in PHP_METHOD()
1130 … pdo_stmt_construct(execute_data, stmt, return_value, dbh->def_stmt_ce, &dbh->def_stmt_ctor_args); in PHP_METHOD()
1136 dbh->query_stmt = stmt; in PHP_METHOD()
1137 ZVAL_COPY_VALUE(&dbh->query_stmt_zval, return_value); in PHP_METHOD()
1154 pdo_dbh_t *dbh = Z_PDO_DBH_P(getThis()); in PHP_METHOD() local
1169 if (!dbh->methods->quoter) { in PHP_METHOD()
1170 pdo_raise_impl_error(dbh, NULL, "IM001", "driver does not support quoting"); in PHP_METHOD()
1174 if (dbh->methods->quoter(dbh, str, str_len, &qstr, &qlen, paramtype)) { in PHP_METHOD()
1304 pdo_dbh_t *dbh = dbh_obj->inner; in pdo_hash_methods() local
1306 if (!dbh || !dbh->methods || !dbh->methods->get_driver_methods) { in pdo_hash_methods()
1309 funcs = dbh->methods->get_driver_methods(dbh, kind); in pdo_hash_methods()
1314 dbh->cls_methods[kind] = pemalloc(sizeof(HashTable), dbh->is_persistent); in pdo_hash_methods()
1315 zend_hash_init_ex(dbh->cls_methods[kind], 8, NULL, in pdo_hash_methods()
1316 dbh->is_persistent? cls_method_pdtor : cls_method_dtor, dbh->is_persistent, 0); in pdo_hash_methods()
1323 func.function_name = zend_string_init(funcs->fname, strlen(funcs->fname), dbh->is_persistent); in pdo_hash_methods()
1358 zend_hash_str_add_mem(dbh->cls_methods[kind], lc_name, namelen, &func, sizeof(func)); in pdo_hash_methods()
1399 pdo_dbh_t *dbh = Z_PDO_DBH_P(object); in dbh_get_gc() local
1400 *gc_data = &dbh->def_stmt_ctor_args; in dbh_get_gc()
1511 static void dbh_free(pdo_dbh_t *dbh, zend_bool free_persistent) in dbh_free() argument
1515 if (dbh->query_stmt) { in dbh_free()
1516 zval_ptr_dtor(&dbh->query_stmt_zval); in dbh_free()
1517 dbh->query_stmt = NULL; in dbh_free()
1520 if (dbh->is_persistent) { in dbh_free()
1522 ZEND_ASSERT(!free_persistent || (dbh->refcount == 1)); in dbh_free()
1524 if (!free_persistent && (--dbh->refcount)) { in dbh_free()
1529 if (dbh->methods) { in dbh_free()
1530 dbh->methods->closer(dbh); in dbh_free()
1533 if (dbh->data_source) { in dbh_free()
1534 pefree((char *)dbh->data_source, dbh->is_persistent); in dbh_free()
1536 if (dbh->username) { in dbh_free()
1537 pefree(dbh->username, dbh->is_persistent); in dbh_free()
1539 if (dbh->password) { in dbh_free()
1540 pefree(dbh->password, dbh->is_persistent); in dbh_free()
1543 if (dbh->persistent_id) { in dbh_free()
1544 pefree((char *)dbh->persistent_id, dbh->is_persistent); in dbh_free()
1547 if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) { in dbh_free()
1548 zval_ptr_dtor(&dbh->def_stmt_ctor_args); in dbh_free()
1552 if (dbh->cls_methods[i]) { in dbh_free()
1553 zend_hash_destroy(dbh->cls_methods[i]); in dbh_free()
1554 pefree(dbh->cls_methods[i], dbh->is_persistent); in dbh_free()
1558 pefree(dbh, dbh->is_persistent); in dbh_free()
1563 pdo_dbh_t *dbh = php_pdo_dbh_fetch_inner(std); in pdo_dbh_free_storage() local
1564 if (dbh->in_txn && dbh->methods && dbh->methods->rollback) { in pdo_dbh_free_storage()
1565 dbh->methods->rollback(dbh); in pdo_dbh_free_storage()
1566 dbh->in_txn = 0; in pdo_dbh_free_storage()
1569 if (dbh->is_persistent && dbh->methods && dbh->methods->persistent_shutdown) { in pdo_dbh_free_storage()
1570 dbh->methods->persistent_shutdown(dbh); in pdo_dbh_free_storage()
1573 dbh_free(dbh, 0); in pdo_dbh_free_storage()
1578 pdo_dbh_object_t *dbh; in pdo_dbh_new() local
1580 dbh = zend_object_alloc(sizeof(pdo_dbh_object_t), ce); in pdo_dbh_new()
1581 zend_object_std_init(&dbh->std, ce); in pdo_dbh_new()
1582 object_properties_init(&dbh->std, ce); in pdo_dbh_new()
1583 rebuild_object_properties(&dbh->std); in pdo_dbh_new()
1584 dbh->inner = ecalloc(1, sizeof(pdo_dbh_t)); in pdo_dbh_new()
1585 dbh->inner->def_stmt_ce = pdo_dbstmt_ce; in pdo_dbh_new()
1587 dbh->std.handlers = &pdo_dbh_object_handlers; in pdo_dbh_new()
1589 return &dbh->std; in pdo_dbh_new()
1597 pdo_dbh_t *dbh = (pdo_dbh_t*)res->ptr; in ZEND_RSRC_DTOR_FUNC() local
1598 dbh_free(dbh, 1); in ZEND_RSRC_DTOR_FUNC()