Ok, I'm setting up an app that tracks user online status, so I have two
models User and Session. I set User association to hasOne Session, and
Session to belongsTo User. In the AppController class constructor I
call a Session function called updateLastActivity($user_id). Here's
the function:
function updateLastActivity($user_id = null) {
$session_id = session_id();
$session = $this->findBySessionId($session_id);
$session['Session']['session_id'] = $session_id;
$session['Session']['user_id'] = intval($user_id);
$session['Session']['last_activity'] = date('Y-m-d H:i:s');
if ($session['Session']['user_id'] > 0) {
$session['User']['last_access'] = date('Y-m-d H:i:s');
}
$this->save($session);
}
Here, I'm expecting that if user_id is set (session belongs to a
registered user), it will update the last_access field in the User
model to which this Session belongsTo. However, when I checked the SQL
debug logs, save only calls an update to the sessions table and none
for the users table. I thought I read somewhere that with
associations, CakePHP takes care of saving associated models to the
database.
Any comments on this? Thank you very much.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---