Created
July 26, 2018 19:59
-
-
Save trycf/e811ec86f0d5a52fd9ce703f897cb5aa to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
qryUserPerm= queryNew("RecID,AccountID,AccessType,AccessLevel,State,City,Building" | |
, "integer,varchar,varchar,varchar,varchar,varchar,varchar"); | |
queryAddRow(qryUserPerm,12) ; | |
foo = [ | |
[ 70,'285A637D82B9','F','B','NY','New York','8010' ] | |
, [ 71,'285A637D82B9','F','B','NY','New York','5412' ] | |
, [ 73,'285A637D82B9','F','B','NY','null','6103' ] | |
, [ 74,'285A637D82B9','F','B','NY','New York','3106' ] | |
, [ 78,'123000000001','F','C','TN','Happytown','1111' ] | |
, [ 79,'123000000001','F','C','TN','Happytown','2222' ] | |
, [ 88,'123000000002','F','S','TN','Anytown','5555' ] | |
, [ 89,'123000000002','F','S','KY','Anytown','2States?' ] | |
, [ 96,'123000000003','V','B','AR','Little Rock','1234' ] | |
, [ 97,'123000000003','V','C','AK','Anchorage','4231' ] | |
, [ 98,'123000000003','F','C','HI','Honolulu', '' ] | |
, [ 99,'123000000003','F','C','LA','Baton Rouge','0000' ] | |
] ; | |
y = 1 ; | |
for (x in foo) { | |
querySetCell(qryUserPerm, "RecID", x[1], y); | |
querySetCell(qryUserPerm, "AccountID", x[2], y); | |
querySetCell(qryUserPerm, "AccessType", x[3], y); | |
querySetCell(qryUserPerm, "AccessLevel", x[4], y); | |
querySetCell(qryUserPerm, "State", x[5], y); | |
querySetCell(qryUserPerm, "City", x[6], y); | |
querySetCell(qryUserPerm, "Building", x[7], y); | |
y++ ; | |
} | |
q2 = queryExecute( | |
"SELECT AccessType, AccessLevel, State, City, Building | |
FROM qryUserPerm | |
WHERE AccountID = ?" , | |
[ { value : "123000000003", cfsqltype : "cf_sql_varchar" } ] , | |
{ dbtype : "query" } | |
) ; | |
//////////////////// BELOW HERE //////////////////// | |
local.permissionType = q2.AccessType ; | |
local.permissionLevel = q2.AccessLevel ; | |
switch( q2.AccessLevel ) { | |
case "S" : local.permissionList = q2.State ; | |
break ; | |
case "C" : local.permissionList = ListRemoveDuplicates(ValueList(q2.City)) ; | |
break ; | |
case "B" : local.permissionList = ListRemoveDuplicates(ValueList(q2.Building)) ; | |
break ; | |
} | |
writeDump(local) ; | |
</cfscript> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment