findAll() multiple criteria in the where clause

119 views
Skip to first unread message

Brad

unread,
Jan 3, 2011, 7:17:50 PM1/3/11
to ColdFusion on Wheels
Happy New Year everyone!
I’m sorry if this is a post on this issue already. I’ve search on
CFWheel Google groups and but didn’t find anything similar to my
problem. This is my first CFWheel application, I’m running CF 8,
CFWheel 1.1.1, and SQL 2000.
The problem is that I’m unable to return anything when using multiple
criteria in the where clause.

This returns zero record.

<cfset supportmenu =
model("menu").findAll(where="categoryGroup='support' and 'show=1",
order="label asc")>
SQL: SELECT
menus.menuID,menus.label,menus.categoryGroup,menus.show,menus.comments,menus.link
FROM menus WHERE menus.categoryGroup = ? ORDER BY menus.label ASC
SQLPARAMETER: array 1 1

This works but it returns all records, I only want to return record
with show being 1.

<cfset supportmenu =
model("menu").findAll(where="categoryGroup='support'", order="label
asc")>

It seem like the show variable name is omitted. I’ve tested the SQL
statement with SQL analyzer and it works fine. Please let me know if
you need any more information. I know it’s probably something I
missed. Any suggestion is much appreciated.

Thank you!

raulriera

unread,
Jan 3, 2011, 7:30:14 PM1/3/11
to ColdFusion on Wheels
Please try this

<cfset supportmenu =
model("menu").findAll(where="categoryGroup='support' AND 'show=1",
order="label asc")>

the same, just uppercase AND (this is a convention in Wheels so the
parser knows how to treat those)

Brandon

unread,
Jan 3, 2011, 11:10:17 PM1/3/11
to cfwh...@googlegroups.com
Thanks for your response Raul! That was it, I knew it was something simple.




--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.


   
 
       
 
 

raulriera

unread,
Jan 4, 2011, 2:39:26 AM1/4/11
to ColdFusion on Wheels
No problem :) Also remember the magic functions, same stuff, just
prettier

<cfset supportmenu =
model("menu").findAllByCategoryGroupAndShow(values="'support',1",
order="label asc")>
> > cfwheels+u...@googlegroups.com<cfwheels%2Bunsubscribe@googlegroups.c om>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/cfwheels?hl=en.
>
>                                                   <#>              <#>
> <#>       <#>

Brandon

unread,
Jan 4, 2011, 12:05:36 PM1/4/11
to cfwh...@googlegroups.com
Very cool, thank you!
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.

Reply all
Reply to author
Forward
0 new messages