Wondering if these checks belong in a gateway, I'll keep it simple:
Assuming I want my service to update a user object only if there's no user 
using the username or email provided by the submitted form.

UserService.cfc
public void function updateUser(username,password,email){
var userid = 0;
userid = usersGateway.getUserByUsername(username);
if(userid eq 0){
userid = usersGateway.getUserByEmail(email);
}
if(userid eq 0){
oUser.save(username,password,email);
}
}

UsersGateway.cfc
public any function getUserByUsername(){
var userid = 0;
//query db: select userid from users where username = #username#
if(qRead.recordcount gt 0){
userid = qRead.userid;
}
return userid;
}
//getUserByEmail() same as above for email query, returns userid = 0 if not 
found.

Basically what I'm fishing for is, do I use the gateway for this type of 
business logic? Considering it is a DB type logic I'm assuming it should stay 
in the data layer, ie Gateway, DAO etc. I wouldn't want my service to do a 
query would I? It just seems to specific and that these kinds of small 
functions could end up making a heavy cfc. 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:339257
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to