JTableUser/setLastVisit: Difference between revisions
From Joomla! Documentation
m clean up |
m preparing for archive only |
||
| Line 4: | Line 4: | ||
===Syntax=== | ===Syntax=== | ||
| Line 69: | Line 69: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=setLastVisit | category=setLastVisit | ||
category=JTableUser | category=JTableUser | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
Latest revision as of 02:12, 25 March 2017
Description
Updates last visit time of user
Syntax
setLastVisit($timeStamp=null, $userId=null)
| Parameter Name | Default Value | Description |
|---|---|---|
| $timeStamp | null | The timestamp, defaults to 'now' |
| $userId | null |
Returns
boolean False if an error occurs
Defined in
libraries/joomla/database/table/user.php
Importing
jimport( 'joomla.database.table.user' );
Source Body
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
Code Examples