开发者

ColdFusion9 and scripted components and hql syntax

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜