Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save trycf/42a23a7faa948c7d68181b2a7efa7a47 to your computer and use it in GitHub Desktop.
Save trycf/42a23a7faa948c7d68181b2a7efa7a47 to your computer and use it in GitHub Desktop.
TryCF Gist
<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