Subversion Repository Public Repository

Nextrek

Diff Revisions 249 vs 250 for /Android/SmartCharging/endPoints/get_immagini.php

Diff revisions: vs.
  @@ -1,5 +1,6 @@
1 1 <?php
2 2 require_once("LocalRepository.php");
3 + require_once("CommentRepository.php");
3 4
4 5 $servername = "localhost";
5 6 $username = "smartcharging";
  @@ -9,25 +10,33 @@
9 10
10 11 $conn;
11 12 $risposta = array();
12 - $local_repo;
13 - $local;
13 + $repo;
14 + $object;
14 15
15 16 try {
16 17 $conn = new PDO("mysql:host=".$servername.";dbname=smartcharging", $username, $password);
17 18 $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
18 19 //echo "Connesso con successo al DB";
19 20
20 - $local_repo = new LocalRepository($conn);
21 + $type = $params["type"];
21 22
22 - $local = $local_repo->getImages($params["id"]);
23 -
24 - if (is_null($local)) {
25 - $risposta["img1"] = "";
26 - $risposta["img2"] = "";
27 - } else {
28 - $risposta["img1"] = $local->img1;
29 - $risposta["img2"] = $local->img2;
30 - }
23 + if ($type=="local") {
24 + $repo = new LocalRepository($conn);
25 + } else if ($type=="comment") {
26 + $repo = new CommentRepository($conn);
27 + } else {
28 + $risposta["type"] = "error";
29 + $risposta["id"] = -1;
30 + $risposta["imgs"] = null;
31 + $risposta["return"] = 1;
32 + }
33 +
34 + $object = $repo->getImages($params["id"]);
35 +
36 + $risposta["id"] = $params["id"];
37 + $risposta["type"] = $type;
38 + $risposta["imgs"] = $object->imgs;
39 + $risposta["return"] = 0;
31 40
32 41 }
33 42 catch(PDOException $e)