coldfusion
cfquery
수색…
매개 변수
| 매개 변수 | 세부 |
|---|---|
| 이름 | 값 : 문자열 , 기본값 : 예 |
| dbtype | 값 : query / hql, 기본값 : no,주의 : 비워두면 정상적인 쿼리입니다. |
| 데이터 소스 | 기본값 : no, 비고 : database |
| 매개 변수 | 값 : 구조 , 기본값 : no, 설명 : cfscript 구문에만 해당! cfml에서 그들은 <cfqueryparam /> |
함수 내에서 cfquery 사용
<cffunction name="getUserById" access="public" returntype="query">
<cfargument name="userId" type="numeric" required="yes" hint="The ID of the user">
<cfquery name="local.qryGetUser" datasource="DATABASE_NAME">
SELECT id,
name
FROM user
WHERE id = <cfqueryparam value="#arguments.userId#" cfsqltype="cf_sql_integer">
</cfquery>
<cfreturn local.qryGetUser>
</cffunction>
검색어 검색어
함수 호출
<!--- Load the user object based on the component path. --->
<cfset local.user = new com.User() />
<cfset local.allUsers = user.getAllUsers()>
<cfset local.specificUser = user.getUserIdFromQry(qry = local.allUsers, userId = 1)>
User.cfc
<cfcomponent>
<cffunction name="getAllUsers" access="public" returntype="query">
<cfquery name="local.qryGetAllUsers" datasource="DATABASE_NAME">
SELECT id,
name
FROM user
</cfquery>
<cfreturn local.qryGetAllUsers>
</cffunction>
<cffunction name="getUserIdFromQry" access="public" returntype="query">
<cfargument name="qry" type="query" required="Yes" hint="Query to fetch from">
<cfargument name="userId" type="numeric" required="Yes" hint="The ID of the user">
<cfquery name="local.qryGetUserIdFromQry" dbtype="query">
SELECT id,
name
FROM arguments.qry
WHERE id = <cfqueryparam value="#arguments.userId#" cfsqltype="cf_sql_integer">
</cfquery>
<cfreturn local.qryGetUserIdFromQry>
</cffunction>
</component>
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow