开发者

ColdFusion9 and scripted components and hql syntax

开发者 https://www.devze.com 2022-12-12 00:17 出处:网络
How can this be rewritten using the new scripting syntax along with the hibernate query language in CF9?

How can this be rewritten using the new scripting syntax along with the hibernate query language in CF9?

<cfcomponent output="no">
<cffunction name="Login" output="no">
    <cfargument name="UsrName">
    <cfargument name="UsrPassword">

    <cfquery name="local.qry">
    SELECT * FROM UsrView
    WHERE UsrNa开发者_开发技巧me = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.UsrName#">
    AND UsrPassword = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.UsrPassword#">
    </cfquery>
    <cfreturn local.qry>
</cffunction>
</cfcomponent>


Is this what you are after?

component{
  public query function Login(UsrName,UsrPassword){
    // get array of entities matching filter
    var arrayOfUsers = EntityLoad('User',{
      UsrName=arguments.UsrName, UsrPassword=arguments.UsrPassword
    });
    // convert entity array to a query object
    return EntitytoQuery(arrayOfUsers);
  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消