Gee, do I feel (extra) stupid. Not only was that the problem, but the msg I sent last night explaining this was sent to myself, not the group. Here's the msg: -- snip -- Arrgghhh! PEBCAK all the way! I created a behavior for dealing with different types of users, which I'm using in addition to Extendable. In the beforeSave() I had forgotten that I'd left--you guessed it-- "return false;" Yeesh!!
I hadn't noticed it because I was planning on not saving anything from the Member model itself. So, I removed that, set the $validate param in save() back in along with the fieldlist, and now all is good. Cripes! I can't believe how many hours I spent dicking around with this. -- snip -- Everything's working like gangbusters now. Once this site is ready for production, I plan on writing up a detailed account about how I dealt with a fairly complicated user-type situation. Thanks for replying. On Tue, Jan 6, 2009 at 8:40 AM, Adam Royle <[email protected]> wrote: > > Can you show your model & app model code? I'm guessing somewhere > you're not returning true from a beforeValidate() or beforeSave() > method. > > Eg. you should do something like this if that's the case. > > function beforeSave() { > > if ( .... ) { > // cancel the save > return false; > } else { > // modify a field before saving > $this->data[$this->alias]['field'] = 'blah'; > } > > // ask our parent if it's ok to save! > return parent::beforeSave(); > > } > > > On Jan 6, 5:13 am, brian <[email protected]> wrote: >> I've gone as far as I can in debugging why a save() is failing. I'd >> appreciate any tips. >> >> The situation: >> >> I have a form on a user's profile page for uploading a headshot image. >> The image is being saved ok. The part that's failing is updating the >> user's record in the DB. >> >> The code: >> $this->Member->recursive = -1; >> $this->data = $this->Member->read(null, $id); >> >> ... // upload and add headhsot info to $this->data['Member'] >> >> $this->Member->validate = array(); >> >> if ($this->Member->save($this->data)) >> { >> $this->flash('image uploaded', $referer);} >> >> else >> { >> //debug($this->data);exit; >> //debug($this->Member->validationErrors);exit; >> $this->flash('DB info not saved', $referer); >> >> } >> >> As you can see, I've disabled validation in an attempt to get this to >> work. And I've also tried dumping both $this-data and >> $validationErrors. The latter, as expected, is empty. The former >> appears perfectly fine. An example: >> >> Array >> ( >> [Member] => Array >> ( >> [id] => 1596 >> [created] => 2009-01-05 03:32:31 >> [modified] => 2009-01-05 13:26:03 >> [last_login] => 2009-01-05 13:26:03 >> ... >> [headshot] => test1_test1.png >> [headshot_width] => 225 >> [headshot_height] => 228 >> [headshot_mimetype] => image/png >> ) >> ) >> >> I've enabled query logging for the DB and dropped this in just before >> the attempt to save: >> >> $this->Member->query("SELECT('SAVING ...')"); >> >> This is the result: >> >> 5 Query SELECT('SAVING ...') >> 5 Query SELECT COUNT(*) AS `count` FROM `users` AS `Member` >> WHERE `Member`.`id` = 1596 >> 5 Quit >> >> That query, used in a terminal, returns 1, as expected. >> >> So, can anyone suggest some other way to debug this failed save? I >> need to figure out why Cake packed it in after that count() query. The >> Model class doesn't seem to have anything else available beside >> $validationErrors. I hunted around a little in DataSource and DboMysql >> but it doesn't appear to be an SQL issue. >> >> In a nutshell, where does one look to learn the reason for a failed >> save? And, as the save method is in the model, why doesn't the model >> expose failed saves? >> >> A note about the users/Member thing: I'm using inheritance here but I >> can confirm that saves do work fine. It's just this one action that's >> giving me trouble. In any case, the point of this is that I don't know >> where to look to find out for sure. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
