-
-
Save dongilbert/4470755 to your computer and use it in GitHub Desktop.
Moved the query from the loop into a sub query and then optimized a little.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function getSubmits() | |
{ | |
$cid = JFactory::getApplication()->input->getInt('cid'); | |
$db = $this->getDbo(); | |
$query = $db->getQuery(true); | |
$query->select('a.*, i.username'); | |
$query->select('(SELECT SUM(v.vote) FROM #__rootflick_vote AS v WHERE v.sub_id = a.id) AS vote'); | |
$query->from('#__rootflick_submissions as a'); | |
$query->leftJoin('#__users as i ON (a.user_id = i.id)'); | |
$query->where('chapter_id='.$cid . ' and winner = 0'); | |
return $db->setQuery($query)->loadObjectList(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment