The following 2 bits of code are part of a much larger function that returns drivers race results and adds them up to get season results. The parts of the function that are not included are working just fine, but I cannot get this to work and I'm hoping for some help.
This first function works properly it adds up all of the drivers points for the season. No problems here.
$sqlQuery = new SQLQuery("SUM(Points)", "Result", "ChampionshipID = '" . $this->ID ."' AND DriverID = ".$doDriver->ID); $spoint = $sqlQuery->execute()->value();
For some championships only a certain number of results count towards the final season total. I have created a field on my championship dataobject 'ResultsForChampionship' that holds a numeric value for the number of results that are to be included, and then I pass that value to the query $limit.
$ResultLimit = $this->ResultsForChampionship; $sqlBestQuery = new SQLQuery(); $sqlBestQuery->select = array('SUM(Points)'); $sqlBestQuery->from = array('Result'); $sqlBestQuery->where = array("ChampionshipID = '" . $this->ID ."' AND DriverID = ".$doDriver->ID); $sqlBestQuery->orderby = "Points DESC"; $sqlBestQuery->limit = $ResultLimit; $sbestpoint = $sqlBestQuery->execute()->value();
This function returns the same value as the first function. Am I misunderstanding what $limit means?
Stumped... Any help would be appreciated.