API16

JTableAsset/loadByName

< 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

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


Advertisement