API16

JTableUser/setLastVisit

From Joomla! Documentation

< API16:JTableUser

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Updates last visit time of user



Syntax[edit]

setLastVisit($timeStamp=null, $userId=null)
Parameter Name Default Value Description
$timeStamp null The timestamp, defaults to 'now'
$userId null

Returns[edit]

boolean False if an error occurs

Defined in[edit]

libraries/joomla/database/table/user.php

Importing[edit]

jimport( 'joomla.database.table.user' );

Source Body[edit]

function setLastVisit($timeStamp = null, $userId = null)
{
        // Check for User ID
        if (is_null($userId))
        {
                if (isset($this)) {
                        $userId = $this->id;
                } else {
                        // do not translate
                        jexit('WARNMOSUSER');
                }
        }

        // If no timestamp value is passed to functon, than current time is used.
        $date = JFactory::getDate($timeStamp);

        // Update the database row for the user.
        $this->_db->setQuery(
                'UPDATE `'.$this->_tbl.'`' .
                ' SET `lastvisitDate` = '.$this->_db->Quote($date->toMySQL()) .
                ' WHERE `id` = '.(int) $userId
        );
        $this->_db->query();

        // Check for a database error.
        if ($this->_db->getErrorNum()) {
                $this->setError($this->_db->getErrorMsg());
                return false;
        }

        return true;
}



Examples[edit]

Code Examples[edit]