Yes, all the methods are in the same component. I'm getting no errors at
all, which is whats making me pull my hair out. When I test this I'm doing
the following:
<cfset user = createObject("component", "user")>
<cfset user.setLogin("test")>
<cfoutput>#user.getLogin()#</cfoutput>
<cfset user.createUser()>
This will display the user name "test" on the page, and will not error when
I run the create user function. When I look at the database, the dates have
been inserted, and spaces for the login / pass / name(s), not null values.
I'm at a complete loss why this is happening.
Rich Kroll
Application Developer
SITE Manageware, Inc.
-----Original Message-----
From: Ryan Guill [mailto:[EMAIL PROTECTED]
Sent: Friday, November 18, 2005 2:17 PM
To: CF-Talk
Subject: Re: Strange CFC behavior
Are the methods you are calling in the same component as the createUser
method?
I guess they must be if you can call variables.instance.something and
get the value...
You arent getting any errors thrown?
On 11/18/05, Rich Kroll <[EMAIL PROTECTED]> wrote:
> Hello all,
> I'm having a weird problem. I've crated a user.cfc that manages all my
user
> information. When the object is created I put all relevant information
into
> the variables scope like:
> <cfset variables.instance = StructNew()>
> <cfset variables.instance.login = "">
> <cfset variables.intance.password = "">
>
> Then I have crud operations to populate the variables:
> <cffunction name="getLogin" access="public">
> <cfreturn variables.instance.login>
> </cffunction>
>
> <cffunction name="setLogin" access="public">
> <cfargument name="login" required="yes" type="string">
> <cfset variables.instance.login = trim(arguments.login)>
> <cfreturn true>
> </cffunction>
>
> All of this works as expected when I create a new user object. If I set
the
> login with user.setLogin("test"), I can call user.getLogin(), and it
returns
> the value that I stored via setLogin().
>
> My problem comes when I try to write this to the database. I've got a
> createUser function that does an insert statement, and when I force it to
> error, the generated SQL is correct, I can run it in query analyzer and it
> inserts correctly, but when I run the function, some functions are
inserting
> the correct data, while anything with a string is not. I also created a
> checkUser() function to ensure that the functions are not being returned
> empty. Below is my createUser function:
>
> <cffunction name="createUser" access="public" output="false">
> <cfif checkUser()>
> <cfquery name="createUser" datasource="#userDSN#">
> INSERT INTO users (login,
> password,
> first_name,
> last_name,
> date_expires,
> date_created,
> created_by,
> updated_by)
> VALUES ('#getLogin()#',
> '#getPassword()#',
> '#getFirstName()#',
> '#getLastName()#',
> <cfif getDateExpires() eq
> "">NULL<cfelse>#getDateExpires()#</cfif>,
> #getDateCreated()#,
> #getCreatedBy()#,
> #getUpdatedBy()#
> )
> </cfquery>
> <cfelse>
> <cfthrow type="site" message="User was not set up properly
> prior to creation" detail="User must have a valid login, password, first
> name, and last name assigned prior to creation">
> </cfif>
> </cffunction>
>
>
> When I run this query, the login, password, first_name, and last_name are
> inserted as empty strings. If I change for example getLogin() to
> variables.instance.login it will insert correctly, and all this function
> does is return the exact same thing. Anyone have any ideas whats going on
> here?
>
> Rich Kroll
> Application Developer
> SITE Manageware, Inc.
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:224677
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54