Thanks Grant, that does make a lot of sense, I do display a form, the xml usually has incomplete data that the user needs to update in the form, so the xml is there just to "seed" the form. I guess I can read an example record from the database and then dump the associative array to a file so I can see how to make sure I populate and empty one correctly? What I was looking for is "best practice", i.e. do people just look at their database and start typing into their associative array or is there some best practice for making sure you get all your fields correct such as dumping a record you have read from the database ?
Grant -----Original Message----- From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Grant Cox Sent: Thursday, October 26, 2006 7:27 AM To: Cake PHP Subject: Re: Application Architecture I'm not sure what you mean by "baking" the model - bake is just a command line application to make model/view/controller stubs (although stubs doesn't give them much justice, they are very functional). Even a "complete" model file will not specify the database fields, except where needed for validation. But anyway. So you have your XML uploaded (and related Quicktime files), you've parsed the XML data, and now you want to save it. Firstly, do you really need the form before saving? If it is just for manual validation before the data is saved to the database, is this really needed unless there is an error? I would suggest that your parsing converts the XML into associative arrays suitable for saving as model data. Yes, this does mean that you need to know the database field names in your parsing/conversion code, but this isn't really that bad (you need to know the XML field/element names too). Rapid development is the key here, rather than over architecting parts that aren't really likely to change. Once you've parsed the XML into an associative array of model data, just save it and rely on the Model's standard validation. If this save fails, display an edit form just like any other edit() action, for manual verification. Of course, this is assuming your XML inserts only a single model row. If it has a number of rows, then it would probably be best to parse and validate the data, and display some kind of summary validation page to the user. If they continue, the file is again parsed, but the models are saved. This is the approach I'm using for uploading a CSV of user data, where if there are problems it is easier for the user to re-upload the file than to use a form to fix each row. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~----------~----~----~----~------~----~------~--~---