english/libraries/joomla/database/table/user.php
/**
	 * Method to load a user, user groups, and any other necessary data
	 * from the database so that it can be bound to the user object.
	 *
	 * @param   integer  $userId  An optional user id.
	 * @param   boolean  $reset   False if row not found or on error
	 *                            (internal error state set in that case).
	 *
	 * @return  boolean  True on success, false on failure.
	 *
	 * @since   11.1
	 */
Method to load a user, user groups, and any other necessary data
from the database so that it can be bound to the user object.

@param   integer  $userId  An optional user id.
@param   boolean  $reset   False if row not found or on error
(internal error state set in that case).

@return  boolean  True on success, false on failure.


Method to load a user user groups and any other necessary data from the database so that it can be bound to the user object . @param integer $userId An optional user id . @param boolean $reset False if row not found or on error ( internal error state set in that case ) . @return boolean True on success false on failure .
function load($userId = null, $reset = true)
	{
		if ($userId !== null) {
			$this->id = $userId;
		} else {
			$userId = $this->id;
		}
		if ($userId === null) {
			return false;
		}
		$this->reset();
		$this->_db->setQuery(
			'SELECT *' .
			' FROM #__users' .
			' WHERE id = '.(int) $userId
		);
		$data = (array) $this->_db->loadAssoc();
		if ($this->_db->getErrorNum()) {
			$this->setError($this->_db->getErrorMsg());
			return false;
		}
		if(!count($data))
		{
			return false;
		}
		$return = $this->bind($data);
		if ($return !== false)
		{
			$this->_db->setQuery(
				'SELECT g.id, g.title' .
				' FROM #__usergroups AS g' .
				' JOIN #__user_usergroup_map AS m ON m.group_id = g.id' .
				' WHERE m.user_id = '.(int) $userId
			);
			$this->groups = $this->_db->loadAssocList('title','id');
			if ($this->_db->getErrorNum()) {
				$this->setError($this->_db->getErrorMsg());
				return false;
			}
		}
		return $return;
	}
function load ( $ userId = null , $ reset = true ) { if ( $ userId !== null ) { $ this -> id = $ userId ; } else { $ userId = $ this -> id ; } if ( $ userId === null ) { return false ; } $ this -> reset ( ) ; $ this -> _db -> setQuery ( 'SELECT *' . ' FROM #__users' . ' WHERE id = ' . ( int ) $ userId ) ; $ data = ( array ) $ this -> _db -> loadAssoc ( ) ; if ( $ this -> _db -> getErrorNum ( ) ) { $ this -> setError ( $ this -> _db -> getErrorMsg ( ) ) ; return false ; } if ( ! count ( $ data ) ) { return false ; } $ return = $ this -> bind ( $ data ) ; if ( $ return !== false ) { $ this -> _db -> setQuery ( 'SELECT g.id, g.title' . ' FROM #__usergroups AS g' . ' JOIN #__user_usergroup_map AS m ON m.group_id = g.id' . ' WHERE m.user_id = ' . ( int ) $ userId ) ; $ this -> groups = $ this -> _db -> loadAssocList ( 'title' , 'id' ) ; if ( $ this -> _db -> getErrorNum ( ) ) { $ this -> setError ( $ this -> _db -> getErrorMsg ( ) ) ; return false ; } } return $ return ; }
Method to load a user, user groups, and any other necessary data
 from the database so that it can be bound to the user object.
Method to load a user user groups and any other necessary data from the database so that it can be bound to the user object .
// Get the id to load. // Check for a valid id to load. // Reset the table. // Load the user data. // Check for an error message. // Bind the data to the table. // Load the user groups. // Add the groups to the user data. // Check for an error message.