Skip to content

Instantly share code, notes, and snippets.

@djuggler
Created June 20, 2017 16:16
Show Gist options
  • Save djuggler/c065f2d42fdb79cc34b7670a0ceaf339 to your computer and use it in GitHub Desktop.
Save djuggler/c065f2d42fdb79cc34b7670a0ceaf339 to your computer and use it in GitHub Desktop.
cfwheels update works with named arguments but not always.
----this works----
user = model("users").findByKey(session.user.id);
user.update(status=params.user.status);
----this throws an error----
user = model("users").findAll("(status<2) AND (createdat<='#DateAdd('d',-14, now())#')");
<cfloop query="referee">
user.update(status=status+1);
</cfloop>
This approach fails too:
user = model("users").findAll("(status<2) AND (createdat<='#DateAdd('d',-14, now())#')");
statuscount = user.status+1;
<cfloop query="user">
user.update(status=statuscount);
</cfloop>
To b clear, the loop works but the update inside the loop fails.
Either approach presents error:
"Cannot invoke method update on an object of type coldfusion.sql.QueryTable with named arguments.
Use ordered arguments instead."
I suspect this has to do with the use of user in cfloop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment