Subversion Repository Public Repository

Nextrek

Diff Revisions 722 vs 723 for /Android/SmartCharging/endPoints/nightly/repositories/CommentRepository.php

Diff revisions: vs.
  @@ -108,6 +108,86 @@
108 108
109 109 }
110 110
111 +
112 + public function getCommentById($id_comment) {
113 + $status = array();
114 +
115 + $queryComment = "SELECT c.id AS id_commento, id_locale, id_user, voto, descrizione, data, username, u.avatar as avatar
116 + FROM commenti as c
117 + LEFT JOIN utente as u ON c.id_user=u.id
118 + WHERE c.id=:id_commento";
119 +
120 + $comment;
121 +
122 + try {
123 +
124 + $stmt = $this->db->prepare($queryComment);
125 + $stmt->bindParam(':id_commento', $id_comment);
126 + $query = $stmt->execute();
127 +
128 + //$query = $this->db->query($queryComment);
129 +
130 + if (!$query) {
131 + $status = createErrorMessage(1, "Errore DB");
132 + $status["comment"] = null;
133 + return $status;
134 + }
135 +
136 + //$row = ($query->rowCount()>0) ? $query->fetch() : null;
137 + $row = ($stmt->rowCount()>0) ? $stmt->fetch() : null;
138 +
139 + if (is_null($row)) {
140 + $status["return"] = 0;
141 + $status["comment"] = null;
142 + return $status;
143 + }
144 +
145 + //$comment_id = $row["id_commento"];
146 +
147 + /* ============= SUPPORTO IMMAGINI NEI COMMENTI DROPPATO =============== */
148 +
149 + /*$imgRow = (!is_null($row["img"])) ? IMAGE_SERVER.IMAGES_PATH.$row["img"] : null;
150 +
151 + if (!isset($comment)) {
152 + $comment = new Comment();
153 + $comment->id = $row["id_commento"];
154 + $comment->id_locale = $id_local;
155 + $comment->id_user = (!is_null($row["id_user"]) && $row["id_user"]!="") ? $row["id_user"] : -1;
156 + $comment->user_avatar = (!is_null($row["avatar"]) && $row["avatar"]!="") ? IMAGE_SERVER.AVATAR_PATH.$row["avatar"] : "";
157 + $comment->username = $row["username"];
158 + $comment->voto = $row["voto"];
159 + $comment->descrizione = $row["descrizione"];
160 + $comment->data = $row["data"];
161 + $comment->imgs = (!is_null($imgRow)) ? array($imgRow) : array();
162 + } else if (!is_null($imgRow)) {
163 + array_push($comment->imgs, $imgRow);
164 + }*/
165 +
166 + /* =========== FINE SUPPORTO IMMAGINI NEI COMMENTI DROPPATO ============= */
167 +
168 + $comment = new Comment();
169 + $comment->id = $row["id_commento"];
170 + $comment->id_locale = $row["id_locale"];
171 + $comment->id_user = (!is_null($row["id_user"]) && $row["id_user"]!="") ? $row["id_user"] : -1;
172 + $comment->user_avatar = (!is_null($row["avatar"]) && $row["avatar"]!="") ? IMAGE_SERVER.AVATAR_PATH.$row["avatar"] : "";
173 + $comment->username = $row["username"];
174 + $comment->voto = $row["voto"];
175 + $comment->descrizione = $row["descrizione"];
176 + $comment->data = $row["data"];
177 +
178 + $status["return"] = 0;
179 + $status["comment"] = $comment;
180 + return $status;
181 +
182 + } catch (PDOException $e) {
183 + echo $e->getMessage();
184 + $status = createErrorMessage(1, "Errore DB");
185 + $status["comment"] = null;
186 + return $status;
187 + }
188 +
189 + }
190 +
111 191 public function addComment($comment) {
112 192 $status = array();
113 193