Re: Return boolean from a CFC query

2011-01-26 Thread Michael Firth
Switch the following line in your query profileID = #Session.Profile.profileID# Also, you may want to consider transferring the session into a local variable to be more flexible with your function call Mike On Jan 26, 2011, at 12:47 PM, Adam Bourg wrote: Here's what I'm trying to do. I'm

Re: Return boolean from a CFC query

2011-01-26 Thread Kelly
So the query comes back with no results if it's a student? Why not do something like? cfif isStudentEmployee.recordcount eq 0 cfreturn true cfelse cfreturn false /cfif On 1/26/2011 12:47 PM, Adam Bourg wrote: Here's what I'm trying to do. I'm building a module that

Re: Return boolean from a CFC query

2011-01-26 Thread Michael Firth
I also want to add when you run a cfc page with a query sometimes when you get an error a blank page will occur without any error information. On Jan 26, 2011, at 12:47 PM, Adam Bourg wrote: Here's what I'm trying to do. I'm building a module that only our Professional Staff can access,

Re: Return boolean from a CFC query

2011-01-26 Thread Kelly
Yep this is true - a cftry/cfcatch helps or just run the query outside of the cfc to see if it's throwing an error. On 1/26/2011 1:03 PM, Michael Firth wrote: I also want to add when you run a cfc page with a query sometimes when you get an error a blank page will occur without any error

Re: Return boolean from a CFC query

2011-01-26 Thread Michael Firth
Kelly is right with the cftry and cfcatch. If you change your query like this it should correct your bug I am thinking because when you write a query the database field has to be on the left. TSQL doesnt know what a session variable is. cfquery datasource=#DSN# name=isStudentEmployee

RE: Return boolean from a CFC query

2011-01-26 Thread Russ Michaels
Sorry if I am repeating what anyone else has said, I didn't read the rest of the thread. If you catch errors inside the CFC using try/catch you can then return then in your return struct to inform your calling page that there was an error. e.g. cfset Foo = MyCFC.method(vars) cfif

Re: Return boolean from a CFC query

2011-01-26 Thread Charlie Griefer
Got a few questions about your CFC method... 1) where is the variable DSN coming from? 2) Should your WHERE be: WHERE profileID = #session.profile.profileID# ? (essentially the reverse of what you have) 3) consider using cfqueryparam in your SQL when using dynamic values (yeah, I know... that's

Re: Return boolean from a CFC query

2011-01-26 Thread Alan Rother
Kelly is right with the cftry and cfcatch. If you change your query like this it should correct your bug I am thinking because when you write a query the database field has to be on the left. TSQL doesnt know what a session variable is. MSSQL doesn't care if the field is on the left or the

Re: Return boolean from a CFC query

2011-01-26 Thread Michael Firth
Alan wrote: MSSQL doesn't care if the field is on the left or the right, it's just running a comparison against the statement. Gotta say thats a first and I have been doing mssql for ten years. I am telling you this is what is causing his error because tsql is not as flexible as you think

Re: Return boolean from a CFC query -- UPDATE: Solved

2011-01-26 Thread Adam Bourg
I solved it with the first couple of posts help. New code: cffunction name=isStudentEmployee returntype=boolean hint=Method to determine if the person logged in is a student or pro staffer, will corelate to a control structure if student employee throw up access denied

Re: Return boolean from a CFC query -- UPDATE: Solved

2011-01-26 Thread Kelly
Awesome! :) On 1/26/2011 1:31 PM, Adam Bourg wrote: I solved it with the first couple of posts help. New code: cffunction name=isStudentEmployee returntype=boolean hint=Method to determine if the person logged in is a student or pro staffer, will corelate to a control structure if

Re: Return boolean from a CFC query -- UPDATE: Solved

2011-01-26 Thread Charlie Griefer
On Wed, Jan 26, 2011 at 11:31 AM, Adam Bourg adam.bo...@gmail.com wrote: I solved it with the first couple of posts help.      cfif isStudentEmployee.recordcount eq 0          cfreturn true      cfelse          cfreturn false      /cfif Glad you got it working. You can tighten that

Re: Return boolean from a CFC query

2011-01-26 Thread Alan Rother
I don't know what to tell you Mike, SQL Server doesn't care, it works either way SELECT * FROM PropImage WHERE 20 = PropertyID works exactly the same as PropertyID = 20 It's just common convention that we use PropertyID = 20 In the internal SQL engine it's just running a logical comparison

Re: Return boolean from a CFC query

2011-01-26 Thread Kelly
This is true. I've done it and it works. It's easy enough to test and see that Alan is correct. On 1/26/2011 1:57 PM, Alan Rother wrote: I don't know what to tell you Mike, SQL Server doesn't care, it works either way SELECT * FROM PropImage WHERE 20 = PropertyID works exactly the

RE: Return boolean from a CFC query -- UPDATE: Solved

2011-01-26 Thread Che Vilnonis
Charlie, is this true only when the return type is Boolean? Otherwise, it should return the actual recordcount, right? Thanks, Che You could also drop the comparison itself since CF does implicit boolean conversion. cfreturn isStudentEmployee.recordcount / ^That'll do the same thing.

Re: Return boolean from a CFC query -- UPDATE: Solved

2011-01-26 Thread Scott Stroz
Actually, these will not return the same value. Lets assume the query returns 0 records. cfreturn isStudentEmployee.recordcount = 0 / will return true cfreturn isStudentEmployee.recordcount / will return false On Wed, Jan 26, 2011 at 1:43 PM, Charlie Griefer charlie.grie...@gmail.com wrote:

Re: Return boolean from a CFC query -- UPDATE: Solved

2011-01-26 Thread Charlie Griefer
Well, it will return the actual recordcount... which is a number. But CF implicitly converts numeric values to boolean values. Any non-zero value is true, while any zero value is false. So given the following code: cfif myCFC.myMethod()do something/cfif ... assuming myMethod returns a numeric

Re: Return boolean from a CFC query -- UPDATE: Solved

2011-01-26 Thread Scott Stroz
Let me correct that. cfreturn isStudentEmployee.recordcount = 0 / will return true but cfreturn isStudentEmployee.recordcount / will evaluate to false On Wed, Jan 26, 2011 at 2:06 PM, Scott Stroz boyz...@gmail.com wrote: Actually, these will not return the same value. Lets assume the query

Re: Return boolean from a CFC query -- UPDATE: Solved

2011-01-26 Thread Charlie Griefer
d'oH! Good catch. So if you go the implicit boolean conversion route, switch the return true for return false... On Wed, Jan 26, 2011 at 12:06 PM, Scott Stroz boyz...@gmail.com wrote: Actually, these will not return the same value. Lets assume the query returns 0 records. cfreturn

Re: Return boolean from a CFC query

2011-01-26 Thread Dave Watts
Gotta say thats a first and I have been doing mssql for ten years.  I am telling you this is what is causing his error because tsql is not as flexible as you think because its procedural and requires you do it in a certain way. This is incorrect. Literal values can be placed on either side

Re: Return boolean from a CFC query -- UPDATE: Solved

2011-01-26 Thread Matt Quackenbush
One last note. You need to var scope your query. cfset var isStudentEmployee = / cfquery name=isStudentEmployee ~| Order the Adobe Coldfusion Anthology now!

Re: Return boolean from a CFC query -- UPDATE: Solved

2011-01-26 Thread Ezra Parker
On Wed, Jan 26, 2011 at 10:43 AM, Charlie Griefer charlie.grie...@gmail.com wrote: cfreturn isStudentEmployee.recordcount = 0 / Unless I'm missing something, this should be: cfreturn isStudentEmployee.recordcount eq 0 / -- Ezra Parker

Re: Return boolean from a CFC query -- UPDATE: Solved

2011-01-26 Thread Charlie Griefer
On Wed, Jan 26, 2011 at 12:30 PM, Ezra Parker e...@cfgrok.com wrote: On Wed, Jan 26, 2011 at 10:43 AM, Charlie Griefer charlie.grie...@gmail.com wrote: cfreturn isStudentEmployee.recordcount = 0 / Unless I'm missing something, this should be: cfreturn isStudentEmployee.recordcount eq 0 /