Tuesday, September 04, 2007

MySQL warning and CakePHP 1.2 error?

I wrote some code about adding users to MySQL Table.

In my table present two unique fields: username & email. Ok?


It's code for adding user:

if($this->User->save($this->data)) {
$this->flash('All good','/login');
$this->redirect(array('action'=>'index'), null, true);
} else {
$this->data['User']['password'] = null;
$this->Session->setFlash('All bad');
(of couse it's fragment!)

So. When debug = 1. And I add user with already present in table username or email, I get

1: SQL Error about key who must be unique
2. I see message: All bad
3. No new records in table.

Now, switch debug level = 0

1. We don't see SQL Error (fine!)
2. We see message "All good"
3. We have new record in table with NON unique email (or username)

Who is wrong???


Post a Comment

Subscribe to Post Comments [Atom]

<< Home