Click here to Skip to main content
12,252,903 members (57,159 online)

Design and Architecture

 
QuestionApplication design code samples Pin
Chesnokov Yuriy12-Jan-11 4:29
memberChesnokov Yuriy12-Jan-11 4:29 
AnswerRe: Application design code samples Pin
Eddy Vluggen12-Jan-11 4:52
memberEddy Vluggen12-Jan-11 4:52 
AnswerRe: Application design code samples Pin
Kevin Marois12-Jan-11 5:54
memberKevin Marois12-Jan-11 5:54 
QuestionSCRUM Pin
Civic0610-Jan-11 9:44
memberCivic0610-Jan-11 9:44 
AnswerRe: SCRUM Pin
Rags151210-Jan-11 17:47
memberRags151210-Jan-11 17:47 
GeneralRe: SCRUM Pin
Civic0611-Jan-11 2:10
memberCivic0611-Jan-11 2:10 
GeneralRe: SCRUM Pin
Rags151211-Jan-11 18:54
memberRags151211-Jan-11 18:54 
GeneralRe: SCRUM Pin
RaviSant17-Jan-11 21:57
memberRaviSant17-Jan-11 21:57 
QuestionObject heuristic Pin
Leslie Sanford5-Jan-11 11:35
memberLeslie Sanford5-Jan-11 11:35 
AnswerRe: Object heuristic Pin
Luc Pattyn5-Jan-11 13:06
mvpLuc Pattyn5-Jan-11 13:06 
GeneralRe: Object heuristic Pin
Leslie Sanford5-Jan-11 13:51
memberLeslie Sanford5-Jan-11 13:51 
GeneralRe: Object heuristic Pin
Luc Pattyn5-Jan-11 14:06
mvpLuc Pattyn5-Jan-11 14:06 
AnswerRe: Object heuristic Pin
paul_717-Jan-11 1:24
memberpaul_717-Jan-11 1:24 
QuestionDatabase Code Pin
Leslie Sanford5-Jan-11 5:46
memberLeslie Sanford5-Jan-11 5:46 
I'm looking for ideas/guidance on how to design serverside functionality for interacting with a database. My situation is pretty typical. I have PHP "scripts" that receive request variables. Based on the parameters passed to it, the script queries a database, formats the returned data in some way, and returns it, usually in JSON format.

I've tried taking various approaches to managing the code for this. For example, I've written sets of functions for querying the databse, e.g. getCustomerByName, getProductsByPrice, etc., with each of these functions containing the necessary SQL code. The problem is that you can have an explosion of these types of functions. And sometimes the queries can get quite nuanced so that you wind up with long named functions like getCustomerByNameAndCountry. This approach doesn't seem to scale well, and has made me a little disillusioned with encapsulating SQL queries in functions.

I was thinking about making functions that are more generalized. Something like getCustomer($columns, $where, $orderBy). In other words, parts of the SQL query would be defined outside of the function and passed in. As long as everything is escaped properly, this should be safe. This approach would mean put the responsibility of parsing the request parameters, determining exactly what is being asked for, and then transforming the request parameters into partial SQL statements that would be passed to general functions for performing the actual query.

But then maybe the functions aren't needed at all?

Anyway, I'm relatively new to DB/severside programming; I've been doing it for less than a year, and I'm still struggling with how to structure a system. Any thoughts are welcome.
AnswerRe: Database Code Pin
dasblinkenlight12-Jan-11 11:42
memberdasblinkenlight12-Jan-11 11:42 
QuestionMatching between product and customer personal information Pin
Yanshof3-Jan-11 20:07
memberYanshof3-Jan-11 20:07 
AnswerRe: Matching between product and customer personal information Pin
dasblinkenlight13-Jan-11 6:24
memberdasblinkenlight13-Jan-11 6:24 
QuestionNeed guidance on designing and preparing MCPD Pin
Rags15123-Jan-11 7:11
memberRags15123-Jan-11 7:11 
AnswerRe: Need guidance on designing and preparing MCPD Pin
Richard MacCutchan4-Jan-11 5:36
mvpRichard MacCutchan4-Jan-11 5:36 
GeneralRe: Need guidance on designing and preparing MCPD Pin
Rags15124-Jan-11 17:21
memberRags15124-Jan-11 17:21 
GeneralRe: Need guidance on designing and preparing MCPD Pin
Richard MacCutchan4-Jan-11 21:39
mvpRichard MacCutchan4-Jan-11 21:39 
QuestionPossible inefficiency in post-increment FOR loop? Pin
Xpnctoc30-Dec-10 15:12
memberXpnctoc30-Dec-10 15:12 
AnswerRe: Possible inefficiency in post-increment FOR loop? Pin
Richard MacCutchan30-Dec-10 23:05
mvpRichard MacCutchan30-Dec-10 23:05 
AnswerRe: Possible inefficiency in post-increment FOR loop? Pin
Luc Pattyn30-Dec-10 23:37
mvpLuc Pattyn30-Dec-10 23:37 
GeneralRe: Possible inefficiency in post-increment FOR loop? Pin
fat_boy31-Dec-10 2:12
memberfat_boy31-Dec-10 2:12 
AnswerRe: Possible inefficiency in post-increment FOR loop? Pin
fat_boy31-Dec-10 2:13
memberfat_boy31-Dec-10 2:13 
AnswerRe: Possible inefficiency in post-increment FOR loop? Pin
Peter_in_27804-Jan-11 18:21
memberPeter_in_27804-Jan-11 18:21 
AnswerRe: Possible inefficiency in post-increment FOR loop? Pin
dasblinkenlight13-Jan-11 2:18
memberdasblinkenlight13-Jan-11 2:18 
QuestionDiagramming? Pin
dawmail33328-Dec-10 22:48
memberdawmail33328-Dec-10 22:48 
AnswerRe: Diagramming? Pin
fat_boy31-Dec-10 2:18
memberfat_boy31-Dec-10 2:18 
QuestionDeveloping to try to make a difference? Pin
Todd Baxter28-Dec-10 3:16
memberTodd Baxter28-Dec-10 3:16 
AnswerRe: Developing to try to make a difference? Pin
Pete O'Hanlon28-Dec-10 3:27
mvpPete O'Hanlon28-Dec-10 3:27 
GeneralRe: Developing to try to make a difference? Pin
Todd Baxter28-Dec-10 5:06
memberTodd Baxter28-Dec-10 5:06 
GeneralRe: Developing to try to make a difference? Pin
jk chan28-Dec-10 21:49
memberjk chan28-Dec-10 21:49 
GeneralRe: Developing to try to make a difference? Pin
Todd Baxter29-Dec-10 3:15
memberTodd Baxter29-Dec-10 3:15 
GeneralRe: Developing to try to make a difference? Pin
jk chan29-Dec-10 4:01
memberjk chan29-Dec-10 4:01 
AnswerRe: Developing to try to make a difference? [modified] Pin
Robert Croll4-Jan-11 3:24
groupRobert Croll4-Jan-11 3:24 
GeneralRe: Developing to try to make a difference? Pin
Todd Baxter4-Jan-11 5:04
memberTodd Baxter4-Jan-11 5:04 
GeneralRe: Developing to try to make a difference? Pin
Robert Croll4-Jan-11 6:21
groupRobert Croll4-Jan-11 6:21 
GeneralRe: Developing to try to make a difference? Pin
Todd Baxter4-Jan-11 6:44
memberTodd Baxter4-Jan-11 6:44 
GeneralRe: Developing to try to make a difference? Pin
Robert Croll4-Jan-11 7:29
groupRobert Croll4-Jan-11 7:29 
GeneralRe: Developing to try to make a difference? Pin
Mycroft Holmes13-Jan-11 12:16
memberMycroft Holmes13-Jan-11 12:16 
GeneralRe: Developing to try to make a difference? Pin
Todd Baxter17-Jan-11 2:37
memberTodd Baxter17-Jan-11 2:37 
GeneralRe: Developing to try to make a difference? Pin
Todd Baxter17-Jan-11 4:08
memberTodd Baxter17-Jan-11 4:08 
QuestionHelp: Which design method should I use for this particular case? Pin
xyzsnl27-Dec-10 2:44
memberxyzsnl27-Dec-10 2:44 
AnswerRe: Help: Which design method should I use for this particular case? Pin
Eddy Vluggen28-Dec-10 7:42
mvpEddy Vluggen28-Dec-10 7:42 
AnswerRe: Help: Which design method should I use for this particular case? Pin
Robert Croll4-Jan-11 3:52
groupRobert Croll4-Jan-11 3:52 
QuestionSome thoughts about virtual methods [modified] Pin
bleedingfingers22-Dec-10 22:46
memberbleedingfingers22-Dec-10 22:46 
AnswerRe: Some thoughts about virtual methods Pin
Luc Pattyn23-Dec-10 1:11
mvpLuc Pattyn23-Dec-10 1:11 
GeneralRe: Some thoughts about virtual methods Pin
Xpnctoc30-Dec-10 17:31
memberXpnctoc30-Dec-10 17:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 29 Apr 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid