Created
December 11, 2023 09:04
-
-
Save trycf/42a23a7faa948c7d68181b2a7efa7a47 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> | |
cfapplication( action="update", nullSupport=true); | |
// struct | |
var thisNull = nullValue(); | |
dump(thisNull); | |
dump( var=thisNull ?: 'is_null', label="from local" ); | |
echo("<hr>"); | |
// address query column | |
var q = queryNew( "nullField", "varchar", [ [ nullValue() ] ] ); | |
dump(q.nullField); | |
dump( var=q.nullField ?: 'is_null', label="from db" ); | |
dump( var=IsNull(q.nullField), label="Is null" ); | |
echo("<hr>"); | |
// address query cell | |
dump(q.nullField[1]); | |
dump( var=q.nullField[1] ?: 'is_null', label="from db" ); | |
dump( var=IsNull(q.nullField[1]), label="Is null" ); | |
echo("<hr>"); | |
// one illustation/benefit why "q.nullField" is a column and not a cell value | |
fullNames=query(first:["Ueli", "Hapi", "Urs"]); | |
loop query=q { | |
// if fullNames.first would simply be the cell value, that would be impossible | |
dump(valueList(fullNames.first)); | |
} | |
// loop a query and not let Lucee autoconvert columns | |
// tradionally as possible | |
loop query=q { | |
row=queryCurrentrow(q); | |
dump(q.nullField[row]); | |
} | |
// but of course you can also loop it without usinf the internal pointer in the query | |
loop from=1 to=queryCurrentrow(q) index="row" { | |
dump(q.nullField[row]); | |
} | |
// you can also use queryEach or for each of course | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment