JTableAsset/loadByName
From Joomla! Documentation
< API16:JTableAsset
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]
Method to load an asset by it's name.
Syntax[edit]
loadByName($name)
Parameter Name | Default Value | Description |
---|---|---|
$name | The name of the asset. |
Returns[edit]
int
Defined in[edit]
libraries/joomla/database/table/asset.php
Importing[edit]
jimport( 'joomla.database.table.asset' );
Source Body[edit]
public function loadByName($name)
{
// Get the asset id for the asset.
$this->_db->setQuery(
'SELECT `id`' .
' FROM `#__assets`' .
' WHERE `name` = '.$this->_db->Quote($name)
);
$assetId = (int) $this->_db->loadResult();
// Check for a database error.
if ($error = $this->_db->getErrorMsg())
{
$this->setError($error);
return false;
}
return $this->load($assetId);
}
Examples[edit]
Code Examples[edit]