API15

JTableUser/setLastVisit: Difference between revisions

From Joomla! Documentation

m removing red link to edit, no existant pages
m preparing for archive only
 
Line 72: Line 72:


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=setLastVisit
  category=setLastVisit
  category=JTableUser
  category=JTableUser
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*

Latest revision as of 01:12, 25 March 2017

Description

Updates last visit time of user

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

setLastVisit($timeStamp=null, $id=null)
Parameter Name Default Value Description
$timeStamp null The timestamp, defaults to 'now'
$id 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, $id=null )
{
        // check for User ID
        if (is_null( $id )) {
                if (isset( $this )) {
                        $id = $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);

        // updates user lastvistdate field with date and time
        $query = 'UPDATE '. $this->_tbl
        . ' SET lastvisitDate = '.$this->_db->Quote($date->toMySQL())
        . ' WHERE id = '. (int) $id
        ;
        $this->_db->setQuery( $query );
        if (!$this->_db->query()) {
                $this->setError( $this->_db->getErrorMsg() );
                return false;
        }

        return true;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

Code Examples