[support] how to get the list of new nodes since last login?

Haisam K. Ido haisam at ido.org
Thu May 3 17:23:16 UTC 2007


uid=$uid

$sql = "SELECT node.uid,watchdog.timestamp, node.changed FROM 
`watchdog`,node where watchdog.message like \'Session closed for%\' AND 
node.changed >= watchdog.timestamp and node.uid=watchdog.uid and 
node.uid=$uid";

I believe that the above query returns all nodes which have changed 
since $uid's last login.

Haisam K. Ido wrote:
> Jason:
>
> This does it for finding out the last time a uid closed their session.
>
> SELECT uid,timestamp FROM `watchdog` where message like 'Session closed 
> for%'
>
>
> Jason Flatt wrote:
>   
>> On Thursday May 3 2007 4:29 am, Haisam Ido wrote:
>>   
>>     
>>> Thanks  Nicolas.  But I don't think that would work because by the time
>>> that query runs the 'login' field in the 'users' table would have been
>>> updated with the latest 'login' time.  Is there another table that keeps
>>> the history of user logins?  I know there must be one since users'
>>> logins are logged.
>>>
>>>     
>>>       
>> You would probably have to create a custom module and use hook_user to get the 
>> login time (from the &$user variable, with either the load, login or update 
>> ops) before Drupal has actually logged in the user, and save it somewhere in 
>> another database table/field, or using the variable_set/get() functions.
>>
>> http://api.drupal.org/api/5/function/hook_user
>>
>>
>>   
>>     


More information about the support mailing list