| GETMETADATA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description
Gets metadata (such as the methods, properties, and parameters of a component) associated with an object that is deployed on the ColdFusion server. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Returns
Structured metadata information: for ColdFusion components (CFCs) and user defined functions (UDFs), a structure; for query objects, an array of structures. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Category
System functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Function syntaxGetMetaData(object) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| See also
CreateObject, QueryAddColumn, QueryNew |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| History
ColdFusion MX 7: Added support for getting query object metadata. ColdFusion MX: Added this function. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Parameters
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Usage
This function provides information about application data, and lets applications dynamically determine the structure of an object and how to use it. This function is useful for CFCs and query objects. The metadata for a CFC includes information on the component and its functions, arguments, and properties. The getMetaData function also returns metadata for user-defined functions that not part of CFCs. The following table lists the data returned by the function for supported object types:
For more information, see "Using introspection to get information about components" in Chapter 10, "Building and Using ColdFusion Components," in ColdFusion MX Developer's Guide. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Example
The following example uses the cfdump tag to display metadata for the utilities CFC that is used by the ColdFusion component browser. It also displays the names and data types of the fields in the cfdocexamples database Employees table. <!--- Create an instance of the Component Explorer utilities CFC.
and get its metadata --->
<cfscript>
componentutils = createObject("component", "cfide.componentutils.utils");
utilmetadata = getMetaData(componentutils);
</cfscript>
<h4>Metadata for the CFC component utilities</h4>
<cfdump var="#utilmetadata#">
<!--- use GetMetadata to get the names and data types of the fields in the
cfdocexamples Employees table --->
<cfquery name="getemployees" datasource="cfdocexamples">
SELECT *
FROM Employees
</cfquery>
<cfset employeemeta=getMetaData(getemployees)>
<h4>The Employees table has the following columns</h4>
<cfloop index="i" from="1" to="#arrayLen(employeemeta)#">
<cfoutput>
#employeemeta[i].name# #employeemeta[i].TypeName#
#employeemeta[i].isCaseSensitive#<br>
</cfoutput>
</cfloop>
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OBJECT | |