API16:JTableAsset/loadByName
From Joomla! Documentation
Description
Method to load an asset by it's name.
Syntax
loadByName($name)
| Parameter Name | Default Value | Description |
|---|---|---|
| $name | The name of the asset. |
Returns
int
Defined in
libraries/joomla/database/table/asset.php
Importing
jimport( 'joomla.database.table.asset' );
Source Body
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
Code Examples