<?php
		header("Access-Control-Allow-Origin: *");
		header("Access-Control-Allow-Headers: access");
		header("Access-Control-Allow-Methods: GET");
		header("Access-Control-Allow-Credentials: true");
		header("Content-Type: application/json; charset=UTF-8");

		include_once '../Database.php';
		include_once 'comment.php';

		$database = new DataBase();
		$db = $database->getConnection();
     
        $id = isset($_GET['id'])?$_GET['id']:0;
		$concepto = new Comment($db);
		try{
			$stmt = $concepto->select("select * from ".$concepto->table_name." where anunciosId=".$id);
		$num = $stmt->rowCount();

		if($num>0){
		    $lista=array();
			while($row =$stmt->fetch(PDO::FETCH_ASSOC)){
				array_push($lista,$row);
			}
			echo json_encode($lista);
		}
		else {
			echo json_encode(array("Mensaje"=>"No se han encontrado registros"));
		}
	}catch(Exeption $e){
		echo json_encode(array("Error"=>"Error ".$e));
	}
	
		
?>
