> Can you think of any reason a delete might not work? I know I have the
> correct ID and the proper permissions to delete records.
>
> Here's the code (obfuscated) from the controller:
>
> // load model
> $this->loadModel("MyModel");
Why are you calling loadModel()? Does the controller not have it in
its $uses array? If you're in, eg. ThingsController, calling
loadModel() should be unnecessary.
> // make sure we have correct ID - double checked this so I know it's
> right
> $this->log($thingToDel["Thing"]["id"], LOG_DEBUG);
> // delete record
> $this->MyModel->delete($thingToDel["Thing"]["id"]);
>
> I checked back in the database and the record I'm trying to delete is
> still there. What's another way I can debug this problem?
What queries, if any, is Cake running? You probably don't have a view
for delete and instead do a redirect. If that's so, comment out the
redirect line and create a temporary delete.ctp. Set debug to 2, try
to delete your record, and then have a look at the SQL debug info.
> Can I
> override the delete method in my model somehow? Thanks in advance for
> any help.
Yes, of course.
public function delete($id, $cascade = true)
{
// do something
parent::delete($id, $cascade);
}
Or, you could call parent::delete() first and do something after. But
that's not as likely as the record would already be gone. Depends on
what you need to do. The important thing is to somewhere call
parent::delete().
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
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