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 cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment