ColdFusion MX Bible phần 4

Một ví dụ tốt khi bạn cần để kiểm soát một giao dịch trong ColdFusion là bất cứ khi nào bạn đang đi qua nhiều hàng dữ liệu từ ColdFusion máy chủ cơ sở dữ liệu, và bạn muốn để đóng gói tất cả những truy vấn vào một giao dịch duy nhất. Ví dụ 10-3 minh họa ví dụ này. | Working with Structures This chapter discusses structures which are the most complex and most useful of the complex data types. You learn what structures are how to use them and when to use them. What is a Structure Simply put a structure is a container for other variables. Structures are like arrays in that they contain programmatically addressable elements but structures name each element rather than simply assigning them numeric positions. Graphically a structure looks as shown in Figure 15-1. Figure 15-1 A graphical representation of a structure. In This Chapter Understanding structures Manipulating structure keys Visualizing complex structures The various notations used in referencing structures Structure copying caveats and solutions Notice that each element in a structure has a name. Always remember that each element in an array has a number while structure elements have names. You see how naming each element is useful throughout the chapter. Creating a Structure As are arrays structures are complex objects with a specific initialization function as the following example shows cfset myStruct StructNew StructNew doesn t take any arguments because structures do not have a simple dimension. As you will see in the section Nested Structures later in this chapter structures may have arbitrarily complex dimensions. If myStruct currently contains a value StructNew destroys the old value and replaces it with an empty structure. 334 Part III The ColdFusion MX Language Adding an Element to a Structure An element in a structure consists of a key and a value. The key is the name of the element and the value is what the element contains. Think of the package as if each element were a variable and the structure a named container of those variables. You can add an element to a structure in multiple ways all of which we discuss in the following sections. StructInsert vs. StructUpdate One way to add an element to a structure is by using StructInsert as follows cfset success .

Không thể tạo bản xem trước, hãy bấm tải xuống
18    22    1    06-12-2022
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.