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 not a question) 4) along those same lines, you should var scope your query name. <cfset var isStudentEmployee = "" />, and then run the cfquery. It may or may not be a big deal for this particular method... but in general, you want to var scope any variable used in a method. This ensures that the variable is bound to that method and that method only. 5) you're running the query, but returning true regardless of the result of the query. Should there perhaps be a conditional in there? 6) As Michael F. suggested, you might want to pass the profileID variable in as an argument to the method. It's generally considered to be bad practice to reference session (or any outside scope) from within a cfc method, as that breaks encapsulation (meaning the method should only know about itself... nothing about the 'outside world'... anything it needs to know should be sent in to it... think "black box"). 7) To see what the query is returning, you can always do a <cfdump var="#isStudentEmployee#" /><cfabort /> right after the </cfquery> and above the <cfreturn>
On Wed, Jan 26, 2011 at 10:47 AM, Adam Bourg <adam.bo...@gmail.com> wrote: > > Here's what I'm trying to do. I'm building a module that only our > Professional Staff can access, I am trying to identify where the person > logged in is a pro staff member or a student staffer. When they log into our > CMS, there is a session variable that returns their profile id. it is: > #Session.Profile.profileID# > > We have two tables: > Table 1: pro_profile > Primary key: profileID > This contains all users, their information etc... > > Table 2: mod_userStatus > Primary key: > Sec Key: profileID > This is simply a primary key with a secondary key of profileID. If a person > is on this list they are a prostaffer, if not they are a student. > > I'm trying to query the database and return boolean if the user exists on > mod_userStatus. If yes, they can access the page, if no, redirect. > > Here's the CFC. > > <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"> > <cfquery datasource="#DSN#" name="isStudentEmployee"> > SELECT > profileID > FROM > mod_userStatus > WHERE > #Session.Profile.profileID# = profileID > </cfquery> > > <cfreturn true> > </cffunction> > > When I run this, it just gives me a blank page, returns nothing and no error. > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:341393 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm