Prometheus
Prometheus

Reputation: 33655

ORMExecuteQuery() count seems to return an array

ORMExecuteQuery() seem to return an array for the following

example = ormExecuteQuery("select count(commentID) as n from pComment c");

output uing cfdump for example would be...
array
[1][x]

where x is count.

How can I just get n as a number and not an array object returned? I want to just getn()

Upvotes: 3

Views: 743

Answers (1)

Sergey Galashyn
Sergey Galashyn

Reputation: 6956

Try this:

example = ormExecuteQuery("select count(commentID) as n from pComment c", true);

Second argument is known as unique, despite it's confusing name it makes exactly what you need: makes function to return single value.

Upvotes: 4

Related Questions