Re: Need Help Coding Database Interactions

2006-02-14 Thread Aaron Roberson
What do you need to do with the structure that your insertNewsSubscriptions method returns? Basically, I would just like some confirmation that it has been inserted. I have used a struct to return both an instert status (success or failure) and the new recordID for other set methods. Since this is

Re: Need Help Coding Database Interactions

2006-02-14 Thread Deanna Schneider
I've learned from years in the trenches. I'm by no means an expert. (My degree is Art History and African Cultural Studies - if that tells you anything.) Read CF-Talk, CFDJ, various blogs. Learn by doing. Pick up some books when you need to. It'll come. What do you need to do with the structure th

Re: Need Help Coding Database Interactions

2006-02-13 Thread James Holmes
The CFDJ is full of this stuff, e.g. the recent article at: http://coldfusion.sys-con.com/read/167939.htm On 2/14/06, Aaron Roberson <[EMAIL PROTECTED]> wrote: > I am going to have to look into this... I am venturing into the > unkown. I have read up on CreateObject, but is was all abstract at t

Re: Need Help Coding Database Interactions

2006-02-13 Thread Aaron Roberson
In the instance example, you'd use CreateObject and call init(userid) once. Then you'd call AddNewsLetter(newsletterid) 3 times instead. I am going to have to look into this... I am venturing into the unkown. I have read up on CreateObject, but is was all abstract at the time. I will also have t

Re: Need Help Coding Database Interactions

2006-02-13 Thread James Holmes
I can answer this bit - yes, a similar situation exists in CF. The CFC is like a class, which you can instantiate with CreateObject() or CFOBJECT. If code uses CFINVOKE, specifying a path to the CFC file, it actually instantiates the CFC first (in the background) and then runs the method. This is

Re: Need Help Coding Database Interactions

2006-02-13 Thread Aaron Roberson
If I may, I would like to give you a little more information about my application. Our organization has one main website, and several supporting websites. What I would like to do is for anyone on any site to be able to register as a user, and for their information to be entered into a single datab

Re: Need Help Coding Database Interactions

2006-02-13 Thread Aaron Roberson
One more thing... My insertNewsSubscriptions method returns a structure. If I instantiate the method within the user method, how do I return the struct and should I add the results to the struct that the user method returns? -Aaron Oh, and where did you learn to program? I am wishing more and mo

Re: Need Help Coding Database Interactions

2006-02-13 Thread Deanna Schneider
I'm no OO expert. I only come at it from CF. So, I can't answer your last question. As to your first question, yes, you'd call the insertNews _after_ you have created the userid. If you do what another person suggested, though, you can actually create the userid (as a UUID) when you create the user

Re: Need Help Coding Database Interactions

2006-02-13 Thread Aaron Roberson
Deanna, Thank you very much. Wether or not I invoke or instantiate, am I correct in assuming that I should pass the userID to the newsmanager after inserting the user into the users table? Otherwise, the db may not let me insert the userID in the linking table without a corresponding userID in th

Re: Need Help Coding Database Interactions

2006-02-13 Thread Deanna Schneider
Yes, that's one way to do it. You can also instantiate an instance of the newsletter cfc and call the methods directly. So..; . > Whether your want to instantiate or invoke depends on the life cycle of your user object and whether or not you want t

Re: Need Help Coding Database Interactions

2006-02-13 Thread Aaron Roberson
Deanna wrote: Well, you could have some object aggregation. So, for example, the user CFC could have an instance of the newsletterManager cfc. So, if a new user is created, and they've requested access to certain newsletters, you'd just run the functions from within the user cfc. Or, if you instant

Re: Need Help Coding Database Interactions

2006-02-11 Thread James Holmes
The MAX(ID) technique only works 100% if you use a serializable transaction in the cftransaction tag, which can impact performance. On 2/12/06, Mike Soultanian <[EMAIL PROTECTED]> wrote: > If you're sure about that, go with it. However, from a previous > conversation, it didn't seem that was the

Re: Need Help Coding Database Interactions

2006-02-11 Thread Mike Soultanian
If you're sure about that, go with it. However, from a previous conversation, it didn't seem that was the consensus... but I could very well be wrong... Mike Aaron Rouse wrote: > It does a transaction in the database itself, assuming the database being > used supports transactions. This would

Re: Need Help Coding Database Interactions

2006-02-11 Thread Aaron Rouse
It does a transaction in the database itself, assuming the database being used supports transactions. This would ensure that you get back the ID that you just inserted. On 2/11/06, Mike Soultanian <[EMAIL PROTECTED]> wrote: > > Aaron Roberson wrote: > > Mike, > > > > I will look into that. I thou

Re: Need Help Coding Database Interactions

2006-02-11 Thread Mike Soultanian
Aaron Roberson wrote: > Mike, > > I will look into that. I thought as long as I wrapped the insert user > query and the select user query (with the max() function) in a > cftransaction tag that I would eliminate race conditions and therefore > would return the correct userID. Is that incorrect? I

Re: Need Help Coding Database Interactions

2006-02-11 Thread James Holmes
I'd do it this way too. You can mix this with the UUID idea; you create the user with a new UUID, get it into the DB etc and then manage this user's newletters with the newsletter manager CFC. It means the newsletter info becomes a property of the user, which makes sense; users have newsletters and

Re: Need Help Coding Database Interactions

2006-02-11 Thread James Holmes
Yes, that avoids the whole issue of autonumbers and also allows you two merge separate databases later on if so desired. On 2/11/06, Aaron Roberson <[EMAIL PROTECTED]> wrote: > Could all of this be avoided if I just used the createUUID() function > to insert a userID into my users table instead of

Re: Need Help Coding Database Interactions

2006-02-10 Thread Aaron Roberson
For reference, here is my user.cfc thus far:

Re: Need Help Coding Database Interactions

2006-02-10 Thread Aaron Roberson
Deanna Schneider wrote: > Well, you could have some object aggregation. So, for example, the user CFC > could have an instance of the newsletterManager cfc. So, if a new user is > created, and they've requested access to certain newsletters, you'd just run > the functions from within the user cfc.

Re: Need Help Coding Database Interactions

2006-02-10 Thread Aaron Roberson
Could all of this be avoided if I just used the createUUID() function to insert a userID into my users table instead of using autonumber? I am starting this thing from scratch, so I could removed the auto_increment from the userID if I have to. I am assuming that I would then pass the UUID to both

Re: Need Help Coding Database Interactions

2006-02-10 Thread Aaron Roberson
Mike, I will look into that. I thought as long as I wrapped the insert user query and the select user query (with the max() function) in a cftransaction tag that I would eliminate race conditions and therefore would return the correct userID. Is that incorrect? About getting the userID to the new

Re: Need Help Coding Database Interactions

2006-02-10 Thread Deanna Schneider
Well, you could have some object aggregation. So, for example, the user CFC could have an instance of the newsletterManager cfc. So, if a new user is created, and they've requested access to certain newsletters, you'd just run the functions from within the user cfc. Or, if you instantiate a user as

Re: Need Help Coding Database Interactions

2006-02-10 Thread Mike Soultanian
remember, max may not give you what you want, especially if another user inserts a record just in between the time when you insert your record and then poll for the max id. I'm not sure if mysql supports nextval (like oracle), but you might want to do something like this instead: http://jamest

Re: Need Help Coding Database Interactions

2006-02-10 Thread Aaron Roberson
Thanks for the link! Actually, I do know how to get the unique ID with the MAX() function in SQL. I guess my real question is how do I pass the unique ID from one method in the users component into another method in the newsletter component? Can anyone help with that? -Aaron On 2/10/06, C. Hat

Re: Need Help Coding Database Interactions

2006-02-10 Thread C. Hatton Humphrey
> I am running MySQL 4.0.25 remotely on my production server and 4.1.12 > on my local box. I can't help you with the CFC's but you mihgt look into this page for some help http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html Hatton ~

Re: Need Help Coding Database Interactions

2006-02-10 Thread Aaron Roberson
No problem, I am running MySQL 4.0.25 remotely on my production server and 4.1.12 on my local box. I have designed part of my newsletter component, here it is thus far:

Re: Need Help Coding Database Interactions

2006-02-10 Thread C. Hatton Humphrey
On 2/10/06, Aaron Roberson <[EMAIL PROTECTED]> wrote: > I have three tables: Users, NewsUsers (linking table), NewsCategories > How do I insert a new user in the user table, retrieve the newly > created userID and insert it into the newsUsers linking table, and > insert the newscatID into the news

Need Help Coding Database Interactions

2006-02-10 Thread Aaron Roberson
I have three tables: Users, NewsUsers (linking table), NewsCategories Users userID (pk) userFirst userLast userEmail userPassword NewsUsers user_ID (fk) newscat_ID (fk) NewsCategories newscatID (pk) newscatTitle How do I insert a new user in the user table, retrieve t