I'm doing a search on MongoDB
and bringing the sum of some values. It correctly brings the values that are there by adding them up. The problem is being when I need to, for example, get the value 1 and add it with the value 2. I have 2 numbers as an example:
Valor 1: 980
Valor 2: 2.094
And the sum of this result is giving 982.094 and it would be 3,074 .
The code I use:
$queryReceitaMeta = $this->mongo_db->aggregate('metas_receita', $aggregate);
if(count($queryReceitaMeta['result']) > 0){
$rowQueryReceitaMeta = $queryReceitaMeta['result'][0];
foreach($meses as $mes){
$totalReceitaMeta += $rowQueryReceitaMeta['soma_'.$mes];
}
}
In this code it adds the result of the whole year, which adds up each month (January-December).
When I hit the "." (point) of the values, then it adds up right. Using the function
str_replace
it works normally.