On Oct 23, 2006, at 10:28 AM, [EMAIL PROTECTED] wrote:
> Data Validation - It's way too simple for what I want. I'm looking for > ways to say, validate a date field is a real date, and then also > validate that it's in an acceptable range (ie: over 14 years old). I'd > also like to be able to set custom error messages based on error. > > Now, it looks like i can do a lot of this if i move more validation > into the controller. I can then feed error messages using > this->set('errorMsg', 'whatever'); and then display errorMsg in my > view's return for an invalidate. However, as I understand it, i should > be doing validation at the model level? Validation is kinda one of those gray area things... Sounds like what you're looking for can be accomodated using Model::invalidate(). http://api.cakephp.org/class_model.html#0044104d42199107f8696994f4fa0437 http://manual.cakephp.org/chapter/validation > I did try some of the snippets out there for overriding invalidate in > app_model.php. I mainly just encountered preg-match errors all over > the > place and they didn't work. You shouldn't need to override it.. just perform your non-regex validation (date checking, CC number checking, uniqueness, etc.) and use invalidate to flag fields as problmatic so Cake can take it from there. > Database Access - Right now I'm just building a simple registration > form for users. I noticed with sql debugging turned on that on the > initial page view, before any of the data is submitted, a sql query is > made to describe the table (DESC `users`). It appears that every page > view using the model/controller/view setup does this query? This looks > to me like unnecessary sql queries. Is there a way to set it so it > only > queries when it actually needs to interact with the database? Yeah, set DEBUG to 0 in /app/config/core.php (production mode). > Views - The tutorials I've found have dealt with pages that interact > with the database for one thing. Like a blog. However, some of my > pages > are going to need to interact with different tables to display all > types of information. My index page for example would show site > announcements, new members, advertisements, maybe even latest forums > posts, etc etc. Users will have a home page that once again would be a > consolidation of various queries of unrelated information. Are there > any tutorials for accomplishing this kind of thing? Controllers can use multiple models at once. Just add something like: var $uses = array('ModelA', 'ModelB', 'ModelC'); At the top of your controller definition. This will allow you to access any of those models at $this->ModelName. > As I said, I'm entirely new to the MVC way of thinking. > > So far though, I'm generally impressed and believe I should definetly > be able to speed up the process of development with Cake, now that I'm > getting my head wrapped around it. Yeah, its waaaay nicer than CI. Good luck and happy baking. -- John --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---