public function load($keys = null, $reset = true)
	{
		if (empty($keys))
		{
			// If empty, use the value of the current key
			$keyName = $this->_tbl_key;
			$keyValue = $this->$keyName;

			// If empty primary key there's is no need to load anything
			if (empty($keyValue))
			{
				return true;
			}

			$keys = array($keyName => $keyValue);
		}
		elseif (!is_array($keys))
		{
			// Load by primary key.
			$keys = array($this->_tbl_key => $keys);
		}

		if ($reset)
		{
			$this->reset();
		}

		// Initialise the query.
		$query = $this->_db->getQuery();
		$query->select('*');
		$query->from($this->_tbl);
		$fields = array_keys($this->getProperties());

		foreach ($keys as $field => $value)
		{
			// Check that $field is in the table.
			if (!in_array($field, $fields))
			{
				$e = new Exception(Lang::txt('JLIB_DATABASE_ERROR_CLASS_IS_MISSING_FIELD', get_class($this), $field));
				$this->setError($e);
				return false;
			}
			// Add the search tuple to the query.
			$query->whereEquals($field, $value);
		}

		$this->_db->setQuery($query->toString());

		try
		{
			$row = $this->_db->loadAssoc();
		}
		catch (Exception $e)
		{
			$je = new Exception($e->getMessage());
			$this->setError($je);
			return false;
		}

		// Check that we have a result.
		if (empty($row))
		{
			$e = new Exception(Lang::txt('JLIB_DATABASE_ERROR_EMPTY_ROW_RETURNED'));
			$this->setError($e);
			return false;
		}

		// Bind the object with the row and return.
		return $this->bind($row);
	}
public function load($keys = null, $reset = true)
	{
		if (empty($keys))
		{
			// If empty, use the value of the current key
			$keyName = $this->_tbl_key;
			$keyValue = $this->$keyName;

			// If empty primary key there's is no need to load anything
			if (empty($keyValue))
			{
				return true;
			}

			$keys = array($keyName => $keyValue);
		}
		elseif (!is_array($keys))
		{
			// Load by primary key.
			$keys = array($this->_tbl_key => $keys);
		}

		if ($reset)
		{
			$this->reset();
		}

		// Initialise the query.
		$query = $this->_db->getQuery();
		$query->select('*');
		$query->from($this->_tbl);
		$fields = array_keys($this->getProperties());

		foreach ($keys as $field => $value)
		{
			// Check that $field is in the table.
			if (!in_array($field, $fields))
			{
				$e = new Exception(Lang::txt('JLIB_DATABASE_ERROR_CLASS_IS_MISSING_FIELD', get_class($this), $field));
				$this->setError($e);
				return false;
			}
			// Add the search tuple to the query.
			$query->whereEquals($field, $value);
		}

		$this->_db->setQuery($query->toString());

		try
		{
			$row = $this->_db->loadAssoc();
		}
		catch (Exception $e)
		{
			$je = new Exception($e->getMessage());
			$this->setError($je);
			return false;
		}

		// Check that we have a result.
		if (empty($row))
		{
			$e = new Exception(Lang::txt('JLIB_DATABASE_ERROR_EMPTY_ROW_RETURNED'));
			$this->setError($e);
			return false;
		}

		// Bind the object with the row and return.
		return $this->bind($row);
	}
public function load ( $ keys = null , $ reset = true ) { if ( empty ( $ keys ) ) { // If empty, use the value of the current key $ keyName = $ this -> _tbl_key ; $ keyValue = $ this -> $ keyName ; // If empty primary key there's is no need to load anything if ( empty ( $ keyValue ) ) { return true ; } $ keys = array ( $ keyName => $ keyValue ) ; } elseif ( ! is_array ( $ keys ) ) { // Load by primary key. $ keys = array ( $ this -> _tbl_key => $ keys ) ; } if ( $ reset ) { $ this -> reset ( ) ; } // Initialise the query. $ query = $ this -> _db -> getQuery ( ) ; $ query -> select ( '*' ) ; $ query -> from ( $ this -> _tbl ) ; $ fields = array_keys ( $ this -> getProperties ( ) ) ; foreach ( $ keys as $ field => $ value ) { // Check that $field is in the table. if ( ! in_array ( $ field , $ fields ) ) { $ e = new Exception ( Lang :: txt ( 'JLIB_DATABASE_ERROR_CLASS_IS_MISSING_FIELD' , get_class ( $ this ) , $ field ) ) ; $ this -> setError ( $ e ) ; return false ; } // Add the search tuple to the query. $ query -> whereEquals ( $ field , $ value ) ; } $ this -> _db -> setQuery ( $ query -> toString ( ) ) ; try { $ row = $ this -> _db -> loadAssoc ( ) ; } catch ( Exception $ e ) { $ je = new Exception ( $ e -> getMessage ( ) ) ; $ this -> setError ( $ je ) ; return false ; } // Check that we have a result. if ( empty ( $ row ) ) { $ e = new Exception ( Lang :: txt ( 'JLIB_DATABASE_ERROR_EMPTY_ROW_RETURNED' ) ) ; $ this -> setError ( $ e ) ; return false ; } // Bind the object with the row and return. return $ this -> bind ( $ row ) ; }
Method to load a row from the database by primary key and bind the fields
to the Table instance properties.

@param   mixed    $keys   An optional primary key value to load the row by, or an array of fields to match.  If not
set the instance property value is used.
@param   boolean  $reset  True to reset the default values before loading the new row.
@return  boolean  True if successful. False if row not found or on error (internal error state set in that case).
@since   2.1.12
Method to load a row from the database by primary key and bind the fields to the Table instance properties .