Skip to content

Commit

Permalink
JTableAsset::loadByName(): replace two sql queries by one (joomla#20671)
Browse files Browse the repository at this point in the history
  • Loading branch information
csthomas authored and ggppdk committed Jun 16, 2018
1 parent 6e43240 commit 129effa
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 129effa

Please sign in to comment.