Subversion Repository Public Repository

Nextrek

Diff Revisions 749 vs 750 for /Android/SmartCharging/endPoints/repositories/LocalRepository.php

Diff revisions: vs.
  @@ -463,18 +463,16 @@
463 463 if ($lat==="" || $lon==="") {
464 464 $harvesinFormulaSQL = "SELECT l.id as id, id_utente_owner, lat, lon, indirizzo, tipologia, nomelocale, telefono, email, sito, l.descrizione as descrizione, n_punti_ricarica,
465 465 avg(c.voto) as stelle
466 - FROM locale l, commenti c
466 + FROM locale l LEFT JOIN commenti as c ON c.id_locale=l.id
467 467 ".$whereClause."
468 - AND c.id_locale=l.id
469 - GROUP BY c.id_locale";
468 + GROUP BY l.id";
470 469 } else {
471 470 $harvesinFormulaSQL = "SELECT l.id as id, id_utente_owner, lat, lon, indirizzo, tipologia, nomelocale, telefono, email, sito, l.descrizione as descrizione, n_punti_ricarica,
472 471 avg(c.voto) as stelle,
473 472 ( 6371 * acos( cos( radians(".$lat.") ) * cos( radians( lat ) ) * cos( radians( lon ) - radians(".$lon.") ) + sin( radians(".$lat.") ) * sin( radians( lat ) ) ) ) AS distance
474 - FROM locale l, commenti c
473 + FROM locale l LEFT JOIN commenti as c ON c.id_locale=l.id
475 474 ".$whereClause."
476 - AND c.id_locale=l.id
477 - GROUP BY c.id_locale
475 + GROUP BY l.id
478 476 HAVING distance < ".$distance/1000.0."
479 477 ORDER BY distance";
480 478 //ORDER BY distance LIMIT 0 , 20"; //nel caso in cui si voglia introdurre il limite di locali vicini
  @@ -503,7 +501,7 @@
503 501 $local["descrizione"] = $row["descrizione"];
504 502 $local["sito"] = $row["sito"];
505 503 $local["n_punti_ricarica"] = $row["n_punti_ricarica"];
506 - $local["stelle"] = $row["stelle"];
504 + $local["stelle"] = is_null($row["stelle"]) ? 0 : $row["stelle"];
507 505
508 506 array_push($local_list, $local);
509 507 }