tags:

views:

56

answers:

2

I'm building the front end of a website that'll be holding data for users. Type of data is name, email, ethnicity, income, pets etc etc. Each person can have a partner (with the same questions) and an infinite number of children (names, dob, gender etc). The user can sign up, and then must be able to log in in the future to update their details if necessary.

The problem I'm having is things are just getting really messy. It all starts with validation have loops to check how many children there are and add then redisplay and set up validators if there is an error. Inserting all the data is easy enough, but my insert_user function has 30 paramaters so far.

Everything's getting annoying and frustrating. Is there an established way to deal with data like this? I'm thinking propel or doctrine may help, and I've had a play with PEAR's HTML_QuickForm with limited success (it can't handle things like "select your ethnicity" and an input for "other" or unlimited children)

I'm sure I'm not the first to have this trouble so what to others do?

A: 

Have a look at Symfony, it will make your life a lot easier. Your datamodel here is pretty simple, but be prepared to learn how Symfony works.

http://www.symfony-project.org/

This is the simplest tutorial I know of : http://articles.sitepoint.com/print/symfony-beginners-tutorial : it should get you up and running in a couple of hours.

slomojo
A: 

When I deal with something like this I start with trying to come up with a good model to make it less complex.

For example, if you have server functions, in php, then you can use ajax calls, in javascript to deal with the display, so, you have separated concerns, so you can focus on having each side do what it does best.

If you want to keep everything in php, and just use form submission, then again, split the two parts so that the parts of the code that deals with display is separate from the api that deals with the database.

This is basically just an MVC structure.

That would be the best way to start, is to go back to your design phase, decide which languages you want to use, and separate the work.

Either way you end up with writing an API to get to the database, and the controller code (which handles getting requests and displaying them) doesn't care what type of database, if there is a database or any of those details, it wants to get the children for a particular person, so that request is given to the API and an array is returned.

James Black
Well if I'm going to use an MVC structure I guess I would be better of to use Symfony/ZF/CodeIgnighter or something instead of reinventing the wheel. I just feel that gives it so much bulk. Essentially it's just users signing up, loggin in and editing their accounts. I like the idea of using ajax, although I will probably have to code in PHP anyway as a fallback
Richard
@Richard - If you don't need an entire framework, just write the code, as, in the process you learn how to do it, and you can ensure it does what you need. You are correct though that you should have a fallback in case javascript it turned off.
James Black