So we recently have been doing a ton more with our new projects using cfscript.
See example below:
VARIABLES.testQuery = new Query(
datasource = "TestDB",
name = "testQueryName",
sql =
"SELECT testCol FROM testTable;"
);
VARIABLES.testQuery = VARIABLES.testQuery.Execute().GetResult();
What does the name attribute even do? If I try to use #testQueryName.testCol# it errors out. I know I can get the data using #testQuery.testCol#, but why not have it work the same as the tag?
AS A SIDE NOTE: Also when using cfscript and creating a query that does an insert, why does it not just return a PostgreSQL returning variable. See example below:
VARIABLES.testQuery = new Query(
datasource = "TestDB",
name = "testQueryName",
sql =
"INSERT into testCol ( testCol )
VALUES ('test' )
RETURNING ID;"
);
VARIABLES.testQuery = VARIABLES.testQuery.Execute().GetResult();
With a tag, the ID is returned, but in the cfsrcipt version, you have to NOT use GetResults() but instead use GetPrefix(). Is there a way to have all this done just like the tag?
FINALLY - Should I scope the query tag into the VARIABLES scope, like VARIABLES.testQuery or just do testQuery?
Thanks in advance!