I'm trying to update a record (last login field) and having problems with
it. I can't see where the error is.
Table col -> `last_login` datetime NOT NULL
[code]
$date = date('Y-m-d H:i:s');
$this->User->read(null, $id); <------- debug here returns a complete array
as I would expect
$this->User->set(array(
'approved' => 1,
'last_login' => $date,
'activation_code' => ''
)
);
$this->User->save();
[/code]
The script moves right past the update like it wasn't even there.
When I try to manually update for the sake of troubleshooting:
$this->User->query("UPDATE users SET approved = 1, last_login = $date,
activation_code = '' WHERE id = $id");
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near '16:54, activation_code = '' WHERE id = 1937' at line 1
*Query:* UPDATE users SET approved = 1, last_login = 2010-05-18 16:54,
activation_code = '' WHERE id = 1937
If I make the change:
$date = date('Y-m-d H:i:s'); TO ---> $date = date('Y-m-d');
(essentially changing it to date instead of datetime) the manual
update goes through but $this->User->set still does not.
It's been a long day and perhaps I'm missing something but the query seems
okay, no? I could understand the error if the table was set up for date
instead of datetime, but that's not the case (`last_login` datetime NOT
NULL)
The login action updates the same field using 'saveField' and has no
issues.
What am I overlooking here?
- Ed
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 [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