Hi,
Thanks for trying the code out - there are no SQL queries within the
__sanitize function and the error as described sounds *really* counter-
intuitive. What version of cake are you using out of interest?
In terms of your controller block, nothing obviously wrong there, you
may wish to consider splitting it into two so you can give better
error messages to users though; BTW, this is cake 1.1.12 code, cake
1.2 is slightly different and I haven't tested the __sanitize function
in 1.2.
if( $this->Model->validates($this->data))
{
if($this->Model->create() && $this->Model->save($this->data))
{
// send a success message
}
else
{
// send a DB error message
}
}
else
{
// let users know their input failed to validate
}
With the controller code split up like that and __sanitize() called in
beforeValidate() it definately works on 1.1.12.
Simplest way to figure out whats going would be to stick a couple of
die("at line xxx") statements in to see where the call is made. At a
guess I would say in the beforeValidate() function of your app model?
If you want to persevere with this approach use my email to get in
touch and I'm happy to spend a bit of time looking at it with you.
Ianh
On Mar 26, 12:12 pm, "Michael Tuzi" <[EMAIL PROTECTED]> wrote:
> @ianh
>
> I followed your instructions, but I am now getting an SQL error during
> validation! I don't understand how, why or where the query takes
> place, but the error I get shows that a query ('__sanitize') is being
> made to the db. I am using Zend's IDE that I purched a few years ago,
> but it isn't possible for me to do much in the way of tracing when I'm
> using CakePHP. I'll keep looking for why this call is made and where.
> I have the standard code block:
>
> if ( $this->Model->create() && $this->Model->save($this->data) )
> {
> $this->Session->setFlash('Message');
> $this->redirect('url');}
>
> else {
> $this->validateErrors($this->Model);
> $this->Session->write('model', $this->data);
> $this->set('model', $this->data);
> $this->render();
> exit();
>
> }
>
> so I don't believe my problem's in the controller.
>
> Thanks,
>
> Michael Tuzi
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---