tags:

views:

281

answers:

2

When I call EntityLoad does it load ALL the data in the table or just sets up a reference or something, because say if i do this:

<cfset test = EntityLoad("Table") />

and then do:

ArrayLen(test)

I get the number of rows in the database. If its doing that then it should be loading all the data, and that is really inefficent, say I have a table with 20x10^5 rows or something, it'll be horrible to load all data just to get the length of the table.

+2  A: 

Without seeing your code, I don't know exactly what you're talking about, but here's the run-down:

EntityLoad w/ 1 argument (the Entity name) is going to load all the Entities with that name from the DB. It does however take some additional (optional) arguments to adjust it's behavior. Instead of describing all of them here I'll point you to the beta documentation and a site giving some further exmaples:

Clint Miller
That was perfect, that link to coldfusion-ria was excatly what I needed!Thanks!
Faisal Abid
Glad to be of help!
Clint Miller
+1  A: 

To do what you are trying to do efficiently without incurring a select * on your table, use HQL.

<cfset hqlQuery = "select count(*) From person" />

<cfset results = ORMExecuteQuery(hqlQuery)[1] />

Terry Ryan