Skip to content

Commit

Permalink
JTableAsset::loadByName(): replace two sql queries by one (#20671)
Browse files Browse the repository at this point in the history
  • Loading branch information
csthomas authored and Michael Babker committed Jun 12, 2018
1 parent ec8973f commit cfb6028
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions libraries/src/Table/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,7 @@ public function __construct($db)
*/
public function loadByName($name)
{
$query = $this->_db->getQuery(true)
->select($this->_db->quoteName('id'))
->from($this->_db->quoteName('#__assets'))
->where($this->_db->quoteName('name') . ' = ' . $this->_db->quote($name));
$this->_db->setQuery($query);
$assetId = (int) $this->_db->loadResult();

if (empty($assetId))
{
return false;
}

return $this->load($assetId);
return $this->load(array('name' => $name));
}

/**
Expand Down

0 comments on commit cfb6028

Please sign in to comment.